美文网首页
By.xpath下拉框一直定位不到

By.xpath下拉框一直定位不到

作者: 莉_aa0c | 来源:发表于2020-04-08 16:59 被阅读0次

    web端代码如下:

    1、直接通过xpath定位,失败

    WebElement text =driver.findElement(By.xpath("/html/body/div[4]/div[1]/div[1]"));

    报错:org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[4]/div[1]/div[1]"}

    2、通过class定位,失败:

    WebElement text =driver.findElement(By.xpath("//*[@class=\"el-select-dropdown__wrap el-scrollbar__wrap\"][2]"));

    报错:org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@class="el-select-dropdown__wrap el-scrollbar__wrap"][2]"}

    求大神帮忙,指点

    相关文章

      网友评论

          本文标题:By.xpath下拉框一直定位不到

          本文链接:https://www.haomeiwen.com/subject/aratmhtx.html