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

DavidRYV
  • 45
  • 7
  • 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. – JeffC Nov 05 '19 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 . – DavidRYV Nov 05 '19 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. – CEH Nov 05 '19 at 21:17
  • @Christine Sure, edited my question. – DavidRYV Nov 05 '19 at 21:42
  • 1
    I see ``, but that's not a true ` – CEH Nov 05 '19 at 21:44
  • @Christine , ok , updated my question, I forgot to add the iframe – DavidRYV Nov 05 '19 at 22:13

1 Answers1

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.

Roman Shabanov
  • 152
  • 2
  • 11