lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
507 stars 115 forks source link

What happened to the parent element? #384

Closed jenniferdnn closed 7 years ago

jenniferdnn commented 7 years ago

Who can tell the different between an element generated from selector/xpath and element generated from parent function? Here is an issue, let parentEl = parent(element "#start-of-content") //this works fine let subEl = unreliableElementsWithin "//*[@id='noExist']" //but when this returns 0 element, the parentEl will be massed up. Please give this a try and let me know whether it happens.

lefthandedgoat commented 7 years ago

Looking at the code, parent is reliable.

I can't try your example because I don't know what page you are running those selectors on.

You can write an xpath selector that is equivalent to your first line. id('start-of-content')/..

Then you could write a selector for the second like this id('start-of-content')/..//id('noExist').

You can test these selectors in chrome dev console by using the $x function like this $x("id('start-of-content')/..") and $x("id('start-of-content')/..//id('noExist')")

Hope this helps!

jenniferdnn commented 7 years ago

Hi Chris, the issue happens regardless which web address. The example I give to you it is this web page. Just get a parent element and save it in variable, and then unreliableElementsWithin find some element, when you get 0 element, the parent element variable will be changed. But when it returns some elements, then no issue. And it probably is the selenium issue. I guess parent function using some selenium function to get parent. And it is the root issue. I will close this ticket for now.

lefthandedgoat commented 7 years ago

It may not be an issue with Selenium. I will try to reproduce. It will be a few days though, I am traveling multiple times over the next few days.

jenniferdnn commented 7 years ago

No worry, I already change to other way dealing my use case. And even you get parent by FindElement(By.XPath(".."), issue is same. The parent element looks like this, image After running unreliableElementsWithin image