- org.openqa.selenium.
SessionNotCreatedException
问题描述
堆栈信息:
org.openqa.selenium.SessionNotCreatedException: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"15008.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=59.0.3071.115)
(Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7600 x86_64) (WARNING: ...
- org.openqa.selenium.
InvalidElementStateException
问题描述
堆栈信息:invalid element state: Element is not currently interactable and may not be manipulated
解决方案
方案一:元素定位错误。定位到的不是要操作的元素,先确定定位路径正确且只有一个。 ...
- org.openqa.selenium.
NoSuchElementException
问题
异常类:org.openqa.selenium.NoSuchElementException
解决方案
1、元素定位路径错误修改定位路径,并先在浏览器中进行测试
2、页面(DOM)未加载完成说明:如果你的元素定位路径中有些节点(元素节点、文本节点等)是通过JS生成的,当DOM加载完成时,JS可能还在执行,而selenium判断页面加载完成应该是不考虑JS的,所以可能会出现页面实际未全部加载完成的情况。
解决方法一线程等待:如1000毫秒;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
解决方法二显示等待:超时时间内,轮询查找,selenium2中默认轮询时间为500毫秒一次。
//示例代码:超时时间内轮询查找
//或者自己设置轮询时间:
//new WebDriverWait(driver, timeOutInSeconds, sleepInMillis);
WebElement we = new WebDriverWait(driver, 3).until(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("testid"));
}
});
//selenium2源码
//参见类:org.openqa.selenium.support.ui.FluentWait<T>
//参见方法:public <V> V until(Function<? ...
- org.openqa.selenium.
WebDriverException
问题
堆栈信息如下:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (255, 575)
(Session info: chrome=60.0.3112.113)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7600 x86_64) (WARNING: The server did not provide ...