1

I have an element to find:

//div[contains(@class, 'bPageBlock')][.//*[.='Agreement Documents']]//div[@class='pbBody']//tr[contains(@class,'dataRow')]//a[text()='View']

The problem is, this finds two elements and I want only one. One is under an iframe and one isn't. It would be easy if I wanted the one under the iframe. I could do

//iframe///div[contains(@class, 'bPageBlock')][.//*[.='Agreement Documents']]//div[@class='pbBody']//tr[contains(@class,'dataRow')]//a[text()='View']

However, as you probably guessed, I want the one that is NOT under the iframe. I don't know how to specify something like //not iframe//. And even if I could, the // would find something one step lower or higher that was not an iframe.

Any suggestions how to find the one NOT under the iframe. The roots and paths other than that all seem to be the same with each other. I have tried lots of different things.

If you want to see the specific iframe:

<iframe frameborder="0" id="RLPanelFrame" name="RLPanelFrame" src="/emptyHtmlDoc.html" title="Hidden Frame - Ignore" style="height: 176px;"></iframe>

Then there are many sub-units under it with auto-generated meaningless IDs.

I don't think I can find each one using driver.find() and get the full xpath and check for "iframe" because selenium does not have an xpath extractor. I guess for each one I could keep getting the parent until I got to //html or //iframe but that would take a long time.

Any suggestions? This with Java and Selenium

NarendraR
  • 7,577
  • 10
  • 44
  • 82
Tony
  • 1,127
  • 1
  • 18
  • 29
  • This sounds like an [X-Y problem](http://xyproblem.info/). Instead of asking for help with your solution to the problem, edit your question and ask about the actual problem. What are you trying to do? – undetected Selenium Oct 12 '18 at 20:28
  • You have 2 elements, one under iframe and one not. Selenium can find element under an iframe only if you switched to it. Your selector should see only 1 element or you have another problem. Share html. – Sers Oct 12 '18 at 21:13
  • See https://stackoverflow.com/questions/23847038/allow-click-to-pass-through-iframe-to-content-behind-it?noredirect=1&lq=1; https://stackoverflow.com/questions/41418413/how-to-overlay-an-iframe-and-allow-click-through – Mate Mrše Oct 15 '18 at 09:39
  • Possible duplicate of [How to overlay an iframe and allow click through](https://stackoverflow.com/questions/41418413/how-to-overlay-an-iframe-and-allow-click-through) – Mate Mrše Oct 15 '18 at 09:40
  • Thanks. I guess what was confusing me is that with Chrome in the Inspect when I put in the xpath it found the ones under the iframe too, but it sounds like driver.find() will not? – Tony Oct 15 '18 at 11:35

0 Answers0