Selenium 2.53和Firefox 46点击

时间:2018-02-06 09:34:19

标签: java selenium firefox xpath

我正在使用Selenium 2.53.0和NetBeans JAVA代码以及FireFox 46

问题:有时候点击方法有效但有时却没有。我尝试过以下方法:

方法一:

WebElement we = this.Driver.findElement(By.xpath(elementXpath));
we.click();

方法二:

Narrator.logDebug(" Clicking element by Xpath : " + elementXpath);
   waitForElementByXpath(elementXpath);
   waitForElementToBeClickableByXpath(elementXpath);
   WebDriverWait wait = new WebDriverWait(Driver, 
   ApplicationConfig.WaitTimeout());

   wait.until(ExpectedConditions.elementToBeClickable(By.xpath(elementXpath)));
                WebElement elementToClick = 
   Driver.findElement(By.xpath(elementXpath));
                elementToClick.click();

方法三:

waitForElementByXpath(elementXpath);
        waitForElementToBeClickableByXpath(elementXpath);
        WebDriverWait wait = new WebDriverWait(Driver, ApplicationConfig.WaitTimeout());
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(elementXpath)));

// WebElement elementToClick = Driver.findElement(By.xpath(elementXpath));

        WebElement we = this.Driver.findElement(By.xpath(elementXpath));

        JavascriptExecutor executor = (JavascriptExecutor) Driver;
        executor.executeScript("arguments[0].click();", we);

方法四:

            WebElement we = this.Driver.findElement(By.xpath(elementXpath));
        Actions builder = new Actions(SeleniumDriverInstance.Driver);
        builder.moveToElement(we).click(we);

        builder.build().perform();

        we.click();

我尝试过只使用ID作为我读过的一些帖子,我尝试将我的selenium升级到3+和gecko webdriver位,然后其他浏览器无效。

0 个答案:

没有答案