Selenium 找不到AWS登录页';邮政信箱
我试图找到AWS登录页面的电子邮件输入框。我尝试了css选择器和xpath,但selenium仍然找不到元素 我的css选择器是Selenium 找不到AWS登录页';邮政信箱,selenium,selenium-webdriver,xpath,css-selectors,Selenium,Selenium Webdriver,Xpath,Css Selectors,我试图找到AWS登录页面的电子邮件输入框。我尝试了css选择器和xpath,但selenium仍然找不到元素 我的css选择器是 #resolver_container > div > input 我的密码是 WebElement emailBox = driver.findElement(By.cssSelector("#resolver_container > div > input")); emailBox.sendKeys(email); 错误是 线程“
#resolver_container > div > input
我的密码是
WebElement emailBox = driver.findElement(By.cssSelector("#resolver_container > div > input"));
emailBox.sendKeys(email);
错误是
线程“main”org.openqa.selenium.NoSuchElementException中的异常:没有这样的元素:无法定位元素:{“方法”:“css选择器”,“选择器”:“#解析器_容器>div>输入”}
(会话信息:chrome=78.0.3904.108)
链接是
我刚刚成功地尝试了以下选择器
#resolving_input.aws-signin-textfield
你能试试吗。你的定位仪没有错,好像你需要等待。使用WebDriverWait:
WebElement emailBox = new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#resolver_container > div > input")));
emailBox.sendKeys(email);
以下内容:
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
您还可以使用id
:
By.id("resolving_input")
Selenium执行代码的速度太快。因此,当您的元素可用时,selenium已经开始搜索相同的元素。这就是为什么你会得到这个例外。再加上一些等等。它会起作用。请编写试用代码和错误堆栈跟踪…我编辑我的问题。在浏览器控制台中搜索时没有问题,但selenium说我找不到它。顺便说一下,我尝试了你的选择器,但它给出了相同的异常。