1

I'm using the latest 78 chromedriver , I'm trying to locate an element inside a modal via CSS Selector, something that looks like this

[data-qa='generalTab'] > [id='ui-id-1']

, I was able to run my tests using chrome driver 76. Now with the updated driver I have the following exception :

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element:

, the element is visible, and the selector is correct , I need to run the test without downgrading to 76.

The element is inside an iframe, and I am switching to the iframe as such:

 private void navGeneralTab() { focusActions.focusPageContent(); focusActions.focusIframeModal(thePackageSetupModalIframe()); scrollIntoView(theGeneralTab()); try { TimeUnit.SECONDS.sleep(5); click(theGeneralTab()); } catch (InterruptedException e) { e.printStackTrace(); } } 
focusActions.focusIframeModal(regPackagesUi.thePackageSetupModalIframe()); public void focusIframeModal(By by) { waitActions.waitForPageLoad(); WebElement element = driver().findElement(by); driver().switchTo().frame(element); } 
<iframe name="jqueryDialogIframe" id="jqueryDialogIframe-0" class="jqueryDialogIframe" data-qa="iframeDialog-0" src="regsetup/inventoryItem.do?inventoryitem_id=1366&amp;displayOrder=1" style="width:100%;height:99%" frameborder="0"> <body id="iframe" class="padded 5889_autow99h"> ... <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist"> <li data-qa="generalTab" class="ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="general" aria-labelledby="ui-id-1" aria-selected="true"><a href="#general" class="ui-tabs-anchor" tabindex="-1" id="ui-id-1">General</a></li> <li data-qa="pricesTab" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="pricesAndFees" aria-labelledby="ui-id-2" aria-selected="false"><a href="#pricesAndFees" class="ui-tabs-anchor" tabindex="-1" id="ui-id-2">Prices &amp; Fees</a></li> <li data-qa="advancedTab" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="advanced" aria-labelledby="ui-id-3" aria-selected="false"><a href="#advanced" class="ui-tabs-anchor" tabindex="-1" id="ui-id-3">Advanced</a></li> <li data-qa="sessionBookingTab" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="sessionBooking" aria-labelledby="ui-id-4" aria-selected="false"><a href="#sessionBooking" class="ui-tabs-anchor" tabindex="-1" id="ui-id-4">Session Booking</a></li> <li data-qa="profileValuesTab" class="ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="profileValues" aria-labelledby="ui-id-5" aria-selected="false"><a href="#profileValues" class="ui-tabs-anchor" tabindex="-1" id="ui-id-5">Profile Values</a></li> </ul> </iframe> </body> 

JQuery CSS

.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; } 

I'm trying to click on General Tab , but I can't find it.

Any ideas ? , Has anyone faced this issue, elements not been located ? , I've already tried using xpath, id, text, scroll until visible.

Found out it's a problem from the driver and Chrome 78:

Possible issue with Chromedriver 78, Selenium can not find web element of PDF opened in Chrome

6
  • Did you add a wait? Did you ensure that the page hasn't changed, e.g. your element is now inside an IFRAME, etc.? We've been running our suites on 78 and having no issues. Commented Nov 5, 2019 at 20:24
  • @jeffC yes, it's inside an IFRAME, created a method to focus on that IFRAME, something like : focusActions.focusIframeModal(regPackagesUi.thePackageSetupModalIframe()); public void focusIframeModal(By by) { waitActions.waitForPageLoad(); WebElement element = driver().findElement(by); driver().switchTo().frame(element); } added a wait an ran step by step , and failed to locate the element , it's kind of weird . Commented Nov 5, 2019 at 21:01
  • 1
    It's hard to answer this question without any context for the page that you are automating. Can you post the HTML for the element you are having an issue with, including the iframe it is contained in? Or, a link to the website you are trying to automate. Nothing appears outright incorrect with your code, so it's hard to track down the issue without any context of the page itself. Commented Nov 5, 2019 at 21:17
  • @Christine Sure, edited my question. Commented Nov 5, 2019 at 21:42
  • 1
    I see <body id='iframe'>, but that's not a true <iframe> element, so you actually don't need to focus the iframe to interact with elements under the <body>. Could you also include your Selenium code that you are using to try to click on the General tab? I don't want to attempt a solution if it's just a duplicate of something you have already tried. Commented Nov 5, 2019 at 21:44

1 Answer 1

1

I faced the same issue. My investigation leads me to this open issue. This issue will probably be fixed at v80. In my case Thread.sleep() helped me. But this is duct tape. I decided not to use it.
Explicit wait doesn't help either. So I'm staying on 76 still.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks!, the workaround worked , I will use this duct tape in the meantime.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.