Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我的Wait()方法在';铬'&';Firefox';但不是在';IE';?_Java_Selenium_Selenium Webdriver_Webdriver - Fatal编程技术网

Java 我的Wait()方法在';铬'&';Firefox';但不是在';IE';?

Java 我的Wait()方法在';铬'&';Firefox';但不是在';IE';?,java,selenium,selenium-webdriver,webdriver,Java,Selenium,Selenium Webdriver,Webdriver,我的Wait()方法适用于“Chrome”和“Firefox”,但不适用于“IE”,有什么想法吗 我已经尝试过使用32位和64位的IEDriverServer.exe(发送键动作很慢),但是下面的方法仍然不符合预期的目标 请注意:我知道上面列出的定位器可以在Chrome和firefox中使用 public void waitAndClickFirstDrivingExperiencesOption(WebElement element) throws Exception { WebDri

我的Wait()方法适用于“Chrome”和“Firefox”,但不适用于“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 {
    }

添加
actionmove的代码并单击
,因为该代码是针对非Firefox浏览器执行的。在极少数情况下,我听说IE中的XPath不一样,这可能会导致您的问题。哪一行出现故障,元素的定位器是什么?