小编Hum*_*uma的帖子

如何在Selenium web Driver中写入等待,直到值填充下拉,然后单击按钮

在我的应用程序中,当我打开一个页面时,会显示一个下拉列表,然后我需要单击一个继续按钮.问题是下拉需要一些时间来加载值,但在我的代码中,它在下拉加载之前单击.我尝试使用隐式wait和thread.sleep但它有时候它工作,有些时候不起作用.码:

       public class Home {

    public static void main(String[] args) throws IOException, InterruptedException 
    {
    File file1 = new File("C:\\Selenium\\IEDriverServer_Win32_2.35.3\\IEDriverServer.exe");
      System.setProperty("webdriver.ie.driver", file1.getAbsolutePath());

   WebDriver driver = new InternetExplorerDriver();
    driver.get("http://10.120.13.100/");

     driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);

    Thread.sleep(3000);

    WebElement clickBtn = driver.findElement(By.id("btnHomeProceed"));
   clickBtn.click(); 
Run Code Online (Sandbox Code Playgroud)

java selenium

2
推荐指数
1
解决办法
8959
查看次数

标签 统计

java ×1

selenium ×1