当我使用下面的代码片段执行一个程序时,单击一个在Windows7+Firefox28上正常工作的链接,但在Windows8+Firefox28上不工作。
页面导航到Flipkart,搜索三星S3,但没有点击选定的项目来打开它的规格,等等。
观察到单击后的打印行被执行。
    public static void main(String[] args) {
    WebDriver d = new  FirefoxDriver();
    d.manage().window().maximize();
    d.get("http://www.flipkart.com/");
    d.findElement(By.xpath(".//*[@id='fk-top-search-box']")).sendKeys("Samsung s3");
    d.findElement(By.xpath(".//*[@id='fk-header-search-form']/div/div/div[2]/input[1]")).click();
    //below is the line where, click which doesn't run on windows8+firefox28
    d.findElement(By.xpath(".//*[@id='products']/div/div/div/div/div/a[contains(.,'Samsung Galaxy S3 (Marble White')]")).click();
    System.out.println("After clicking on selected item..."); 
    }发布于 2014-04-19 12:47:25
在某些情况下,click()不能直接工作。在这些情况下,您可以尝试使用sendkey方法。
driver.findElement(By.xpath("blah")).sendKeys(Keys.ENTER);我不确定原因,但它的工作时,点击不起作用。
https://stackoverflow.com/questions/23167291
复制相似问题