FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

XPath on WebElement (chained) does not return correct WebElement #1075

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
See http://goo.gl/ll2FvQ for common issues.

Issue Description:
In my application i have many dynamic objects with the same 
description/properties, therefore i am using parent objects to query ultimate 
desired object.

my code goes here. 
driver.findElement(By.Xpath("myxpath expression to find a 
table")).findElements(By.tagName("tr")).get(0).findElements(By.tagName("td")).ge
t(0).findElement(By.xpath("my xpath expression 2"))

my xpath expression 2 is : "//div[@class='amount']"

OK, so now the issue is there are more than 1 div which has class=amount 
if i will run this expression on document, it should return me array and from 
selenium, 1st index out of that array. 

but if i will run this expression on the element context it should return me 
only 1 element (or array with 1 elm, which is inside a table cell), in selenium 
i am still getting the first element (which is a critical issue).

I have tested my xpath expression in chrome dev tools, it gives results as 
expected. 

Thanks,
Manish Bansal

Original issue reported on code.google.com by qualityk...@gmail.com on 8 Apr 2015 at 4:06

GoogleCodeExporter commented 9 years ago
Could you please provide a reproducible html test page , testcode and What 
chromedriver version are you using?

Original comment by gmanikp...@chromium.org on 8 Apr 2015 at 6:12

GoogleCodeExporter commented 9 years ago
qualityking@

could you please reply to comment#1 and let us know reproducible steps to 
recreate the issue locally here.

thanks

Original comment by agau...@chromium.org on 21 May 2015 at 12:18

GoogleCodeExporter commented 9 years ago
I am afraid its our companies internal application carrying financial data.. I 
might fall into trouble sharing even html of the page.. I will try to write the 
html myself to reproduce the scenario in weekend and comeback here with the 
sample.

Thanks,
Manish Bansal

Original comment by qualityk...@gmail.com on 22 May 2015 at 4:15

GoogleCodeExporter commented 9 years ago
qualityking

we can use xpath index to find the correct element if there are multiple 
elements with same xpath

In your second xpath you can place an index as "(//div[@class='amount'])[2]" 
which will return second amount element

Please try with xpath index and let us know if you still facing the issue with 
latest chromedriver.

Original comment by ssudunag...@chromium.org on 18 Jun 2015 at 11:15

GoogleCodeExporter commented 9 years ago
qualityking@

has solution mentioned in comment#4 solved your problem ?
if yes please let us know so we can close this ticket.

thanks

Original comment by agau...@chromium.org on 15 Jul 2015 at 6:23