简体   繁体   English

如果 Selenium 花费更多时间以防下拉列表中不存在值,我该怎么办?

[英]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?在这种情况下我该怎么办?

  1. 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 秒钟。

  1. Or you can skip the test as suggested above by DebanjanB.或者你可以跳过上面由 DebanjanB 建议的测试。

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.

相关问题 如何在 Mac 上使用 Jenkins 运行 selenium 测试用例? - How do I run a selenium test case using Jenkins, on a mac? 当用户输入不正确的值时,我该怎么办才能循环使用案例结构 - What can i do to loop a case structure when the user entered an incorrect value 硒-如何检查和增加下拉值(如果已经存在)? - Selenium - How to check and increment dropdown value if it is already present? 如何在项目出现之前返回节点的值? - How do I return the value of the node before an item is present? 如何在java中打印内存地址中存在的值? - How do I print the value present in memory address in java? 在编程比赛中接受输入时,如何阻止扫描仪读取输入? - When taking input in programming competitions, what do I do to stop the scanner from reading input? 什么是.next(); 在这种情况下怎么办? - What does .next(); do in this case? 在这种情况下,我需要Java String.split使用什么正则表达式 - What regex do I need for Java String.split for this case Selenium入门指南,我做错了什么? - Selenium Getting Started Guide, What did I do Wrong? 这是什么类型的窗口,我如何用 Selenium 处理它? 自动? - What kind of window is this and how do I handle it with Selenium? Autoit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM