Hey there! any question in your mind? Ask It Now!.

Popular Categories





How to Automate a Dynamic page through Selenium Web Driver?

+1 vote
2,239 views
asked in Software Testing by ramesh (630 points)
edited by Bhartesh
I am trying to automate a page in which row comes dynamically, i mean some time the page is containing 3 rows some times 9 rows.
Is there any way so that i can count available rows or tr in tables or div So that i can put condition after counting the rows by xpath , if you have any idea so please let me know with a example.
Thanks in advance! 

1 Answer

+1 vote
answered by seleniumGuru Expert (4,570 points)
selected by ramesh
 
Best answer
Nice Question , For this situation we will count the avalable row in web page, Lets see a example of <ul> and <li>
here li are dynamic see this example.  
 int size = driver.findElements(By.xpath("//*[@id='demo_ID']/ul/li")).size();
 
  NOTE : here you need to use findElemets not findElemet .
  
  for(int i=1;i<=size;i++){
  
  WebElement text =  driver.findElement(By.xpath("//*[@id='demo_ID']/ul/li["+i+"]/div[4]/p[3]/span[1]"));
  
  String strGetContent = text.getText();
  System.out.println(strGetContent);
  
  }
  
Here we will get the all available row's content in web page, I hope you got my point , if you have any problem so let me know.
 
commented by ramesh (630 points)
Thanks Sir , I got your point its a very nice way to deal with dynamic pages.

Related Questions

+2 votes
1 answer 1,241 views
+5 votes
7 answers 14,590 views
+1 vote
1 answer 544 views
+2 votes
1 answer 134 views
+11 votes
1 answer 123 views
+1 vote
1 answer 2,605 views
+2 votes
2 answers 817 views

Not a Member yet?

Ask to Folks Login

My Account
1060 Folks are online
69 members and 991 guest online
Your feedback is highly appreciated