为什么selenium的expectedconditions.elementtobeclickable(by.xpath(xpath)))返回一个字符串?

hsvhsicv  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(192)

我的代码的简化版本。

do {
    try {
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(xpLucka)));
        driver.findElement(By.xpath(xpLucka)).click();
        System.out.println("Clickable = " + ExpectedConditions.elementToBeClickable(By.xpath(xpSvar)));
    } catch (Exception e1) {
        e1.printStackTrace();
    }
} while (ExpectedConditions.visibilityOfElementLocated(By.xpath(xpSvar)) == null);

我对点击有一些问题 xpLucka ,它需要几次尝试才能成功,因此这是一个丑陋的临时解决方案-但它仍然失败。在javadoc中 elementToBeClickable 以及 visibilityOfElementLocated (我对这两种方法都做过练习,而且在同一个家庭里也做过其他几种方法的练习) returns ,webelement一旦定位并可单击(可见并启用),但当我打印值时,它会打印我用作定位器的xpath( xpSvar ).
我错过了什么?因为,在下一步,我尝试点击 xpSvar 我明白了 NoSuchElementException -因为我还在我应该点击的地方 xpLucka . 很明显 xpLucka 尚未单击并 xpSvar 不可单击或不可见。
编辑:为什么xpath很重要?
不管怎样,这是xplucka //div[@class='calendar-scratcher__container ng-scope']//div[@class='calendar-scratcher-field ng-scope ng-isolate-scope calendar-scratcher-field--interact-click'] 和xpsvar //ul[@class='question__answers ng-scope question__answers--text question__answers--has-active-state question__answers--align-center']/li[@class='question__answer-item question__answer-item--h6'][x]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题