By.xpath下拉框一直定位不到
2020-04-08 本文已影响0人
莉_aa0c
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]"}
求大神帮忙,指点