简体   繁体   English

我可以在firefox中打开URL'http://www.demo.guru99.com/V4/',但是当我在Eclipse中运行selenium脚本时,它显示“连接已超时”

[英]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.

相关问题 如何点击购物车页面中的“更新”按钮-Url =“ http://live.guru99.com/” - How to make click on the Update Button in the shopping Cart Page - Url=“http://live.guru99.com/” chrome 无法在 Selenium Webdriver 中运行。 我正在使用硒 3.0.1 铬 v-54.0 - chrome is not able to run in Selenium Webdriver . i am using selenium 3.0.1 chrome v-54.0 无法从 PgBouncer 打开连接(连接尝试超时) - Not able to open connection from PgBouncer (Connection attempt timed out) 我无法在Selenium 3.10.0中启动Firefox 0.19.1 - I am not able to launch Firefox 0.19.1 in Selenium 3.10.0 网址连接超时 - Url Connection timed out Selenium Webdriver中如何处理“连接已超时” - How to handle 'connection has timed out' in Selenium Webdriver 我是使用Java(Eclipse)刚接触Selenium的人,在使用Firebug时无法确定xpath的问题 - I am new to Selenium, using Java(Eclipse), I am having issues figuring out the xpath when using firebug 硒网格连接超时 - selenium grid connection timed out 在 selenium Java 中获取“等待脚本完成超时”,而我没有在脚本中使用任何异步代码 - Getting “Timed out waiting for script to complete” in selenium Java whereas I have not used any asynchronous code in script 我可以使用此代码打印出客户订购的商品吗? - Am I able to print out what the customer has ordered with this code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM