【问题标题】:Selenium Webdriver - Element not visibleSelenium Webdriver - 元素不可见
【发布时间】:2016-07-12 05:53:40
【问题描述】:

我是 selenium webdriver 的新手。我正在尝试注册http://way2automation.com/way2auto_jquery/index.php

我能够切换到弹出并能够填充所有字段值。但是当我尝试点击 SUBMIT 按钮时,它显示异常Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible

我使用 Xpath 的代码如下:

driver.findElement(By.xpath(".//*[@id='load_form']/div/div[2]/input")).click();

HTML 是:

<div class="span_1_of_4" align="center">
<input class="button" type="submit" value="Submit">

任何帮助将不胜感激。提前致谢

【问题讨论】:

标签: java selenium selenium-webdriver


【解决方案1】:

正如我在您提供的网站url 中看到的那样,存在两个Submit 按钮,因此当您使用xPath .//*[@id='load_form']/div/div[2]/input 时,它会返回两个提交按钮,然后单击第一个Submit 按钮在表格上看不到,所以你应该尝试如下:-

driver.findElement(By.cssSelector("div#load_box input.button")).click();

希望它会起作用..:)

【讨论】:

    【解决方案2】:

    以下方法对我来说很成功:

    WebElement ele=driver.findElement(By.cssSelector("div#load_box input.button")));
    WebDriverwait wb= new WebDriverwait(20,driver)l
    wb.until(ExpectedConditions.ElementVisible(ele)));
    ele.click();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-03
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-10
      • 1970-01-01
      相关资源
      最近更新 更多