[英]I am able to open URL'http://www.demo.guru99.com/V4/' in firefox,but when I run selenium script in eclipse it shows 'The connection has timed out'
我可以在firefox中打开一个URL,但是当我在Eclipse中为相同的脚本运行selenium脚本时,它没有加载,显示为: “连接已超时www.demo.guru99.com上的服务器也在占用很想回应。”
Try to increase the timeout to ensure that the objects are available to selenium. 尝试增加超时时间,以确保硒可以使用这些对象。 To handle the error, better include this code in @BeforeTest or @BeforeSuite annotation which ensure the entire test suite will not run if this fails.
要处理该错误,最好将此代码包含在@BeforeTest或@BeforeSuite批注中,以确保如果失败,则整个测试套件将不会运行。 You can also use try/catch to catch the error and throw exception.
您还可以使用try / catch捕获错误并引发异常。 Choose whatever is best solution in your case.
选择适合您情况的最佳解决方案。
you can define separate functions to handle errors like code: 您可以定义单独的函数来处理类似代码的错误:
public static Boolean IsObjectExists(WebDriver driver, By locator) {
driver.manage().timeouts().implicitlyWait(500, TimeUnit.MILLISECONDS);
try {
driver.findElement(locator);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return true;
} catch (NoSuchElementException e) {
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.