[英]What do i do if Selenium taking more time in case value is not present in dropdown?
I am trying to select values from a Drop down list,but in current build one list item is removed and in code i've mentioned removed list item name.While executing selenium script,it is taking more time,instead of any exception,below is my code.我正在尝试从下拉列表中选择值,但在当前构建中删除了一个列表项,并且在代码中我提到了删除的列表项名称。在执行 selenium 脚本时,它需要更多时间,而不是任何异常,如下是我的代码。
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
dropdown.selectByValue("HomeAdderess")
What should i do in this case?在这种情况下我该怎么办?
I think an implicit wait is set for a large amount( ie 30,40 or 60 seconds).我认为为大量设置了隐式等待(即 30,40 或 60 秒)。 You can simply reduce the time by setting implicit wait.您可以通过设置隐式等待来简单地减少时间。
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS) ; driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS) ;
It will only wait for 5 seconds.它只会等待 5 秒钟。
You can create a different wait variable for these kind of tests.您可以为这些类型的测试创建不同的等待变量。 Or you can write a custom method to handle it verifyElementNotPresentOnDropdown()或者您可以编写一个自定义方法来处理它 verifyElementNotPresentOnDropdown()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.