Problem using chromedriver 78.0.3904.70 locators

Deadly 提交于 2019-12-24 06:42:43

问题


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


回答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.



来源:https://stackoverflow.com/questions/58717681/problem-using-chromedriver-78-0-3904-70-locators

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!