【问题标题】:Selenium webdrive page not loaded - tried to find invisible element and WaitSelenium webdriver 页面未加载 - 试图找到不可见元素并等待
【发布时间】:2012-09-05 19:14:12
【问题描述】:

您好,我正在学习 Webdriver。我正在自动化的流程有 5 个屏幕。 2 个屏幕,我能够使用 webdriver 进行导航。在第二个屏幕中输入详细信息并单击 ENTER 后,Webdriver 浏览器中没有加载第三个屏幕。

当我手动尝试此操作时,效果很好。我已经尝试了各种等待页面加载和搜索不可见元素的逻辑。

这是 webdriver 浏览器的一些限制吗?

   WebDriver driver = new FirefoxDriver();


   driver.get("url");         
  // Find the text input element by its name         
  WebElement element = driver.findElement(By.className("clicButton"));
   // Enter something to search for 
  element.click();
  System.out.println("completed start");
  WebElement element1 = driver.findElement(By.name("contactphone"));
  element1.sendKeys("number");          
  // Now submit the form. WebDriver will find the form for us from the element   
  //element1 = driver.findElement(By.id("the id"));
  //element1.click();
  element1.sendKeys(org.openqa.selenium.Keys.ENTER); 
  System.out.println("clicked continue");
  //WebDriverWait wait = new WebDriverWait(driver,10);
  //WebElement element2 = wait.until(driver.findElement(By.name("name")));

  //wait.until(driver.findElement(By.name("name")).isDisplayed());

  new WebDriverWait(driver, 60)
       .until(ExpectedConditions.presenceOfElementLocated (By.name("name")));

线程 "main" org.openqa.selenium.TimeoutException 中的异常:等待 60 秒后超时,等待存在以下元素:By.name: name 构建信息:版本:“未知”,修订:“未知”,时间:“未知” 系统信息:os.name:'Windows XP',os.arch:'x86',os.version:'5.1',java.version:'1.6.0_20' 驱动程序信息:驱动程序版本:未知 在 org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:255) 在 org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:270) 在 org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:222) 在 LoadUsers.main(LoadUsers.java:49) 原因:org.openqa.selenium.NoSuchElementException:无法定位元素:命令持续时间或超时:0 毫秒

【问题讨论】:

    标签: firefox webdriver


    【解决方案1】:

    几个选项:

    1. 尝试使用 Keys.Return 而不是 Keys.Enter
    2. 尝试在输入元素而不是提交按钮上执行 element1.SendKeys(Keys.Return)。
    3. 看看这个:typing-enter-return-key-in-selenium

    【讨论】:

      猜你喜欢
      • 2012-07-07
      • 2021-02-17
      • 2012-07-12
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      相关资源
      最近更新 更多