简体   繁体   中英

Strange XPath behavior

Admittedly, I don't have much experience in selenium or advanced website building but this has had me stumped for a few days now

After trying to get selenium to find this one element 20 different ways, I ended up just using chromes console to try and find it through there with the $x() command. That's where I really got confused though, I have no idea why it's not finding it one second, then magically finding it the next

here's what the console output looks like:

奇怪的 xpath 行为

Strangely enough, even when I click on the element and retry the above xpath command, it still can't find it. The only way that i can get it to find the element is if I use chromes ctrl + shift + c command to click on the element and see it in element tab. I can't right click and inspect the element because it brings up it's own menu, it only works through that shortcut or clicking the button that activates that command.

I have a feeling this is why my Selenium script can't find the element and I'm not sure how to fix it or even why it's happening. Any input that could help wrap my head around this would be appreciated greatly, thank you!

The element I wanted to click on was hidden under THREE iFrames which is why it couldn't find it. After switching through them, the script functioned correctly - Thank you to Kajal Kundu for his simple question of asking for the HTML, I don't know why I didn't think of iframes possibly messing it up until I started copying the code for him :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM