我的Wait()方法适用于'Chrome'& 'Firefox',但不是'IE'?

时间:2017-01-20 16:17:36

标签: java selenium selenium-webdriver webdriver

我的Wait()方法适用于'Chrome'& '火狐'但不是'IE',任何想法?

我尝试过使用32位和64位的IEDriverServer.exe(发送键动作缓慢),但是下面的方法仍然需要点击预定的目标。

请注意:我知道定位器很好,如上所列适用于Chrome和Firefox。

public void waitAndClickFirstDrivingExperiencesOption(WebElement element) throws Exception {
    WebDriverWait wait2 = new WebDriverWait(driver, 30);
    Base_Page basePage = new Base_Page(driver);
    try {
        System.out.println(basePage.browser_type);
        Boolean elementPresent = wait2.until(ExpectedConditions.elementToBeClickable(element)).isEnabled();
        if (elementPresent == true) {
            if (!this.browser_type.equals("firefox")) {
                // Provide a slight timeout before clicking on the element
                basePage.scrollToElementByLocator(element);
                Thread.sleep(1000);
                basePage.actionMoveAndClick(element);
            } else {
                Thread.sleep(500);
                basePage.scrollToElementByLocator(element);
                Thread.sleep(1000);
                element.click();
            }
        }
        System.out.println("Clicked on the first supercars link, using locator: " + element.toString());
    } catch (StaleElementReferenceException elementUpdated) {
        element = this.driver.findElement(By.xpath(".//*[@id='prd_listing']/div/li[1]/a"));
        Boolean elementPresent = wait2.until(ExpectedConditions.elementToBeClickable(element)).isEnabled();
        if (elementPresent == true) {
            if (!this.browser_type.equals("firefox")) {
                basePage.scrollToElementByLocator(element);
                Thread.sleep(1000);
                basePage.actionMoveAndClick(element);
            } else {
                Thread.sleep(500);
                basePage.scrollToElementByLocator(element);
                Thread.sleep(1000);
                element.click();
            }
        }
        System.out.println(
                "Clicked on the first supercars link (Stale Exception), using locator: " + element.toString());
    } catch (Exception e) {
        System.out.println("Exception! - could not click on the first supercars link, Exception: " + e.toString());
        throw (e);
    } finally {
    }

0 个答案:

没有答案