Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.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
Javascript selenium webdriver中的IE问题?_Javascript_Java_Python 2.7_Selenium_Selenium Webdriver - Fatal编程技术网

Javascript selenium webdriver中的IE问题?

Javascript selenium webdriver中的IE问题?,javascript,java,python-2.7,selenium,selenium-webdriver,Javascript,Java,Python 2.7,Selenium,Selenium Webdriver,我在IE中使用webdriver代码时遇到鼠标悬停的问题,它在Chrome和Firefox中运行良好,但鼠标悬停问题只在IE中出现。我如何解决这个问题?首先关注一个元素,然后点击链接,请看下面的代码 WebElement newbutton = driver.findElement(By.xpath("//html/body/div/span/form[2]/div/div/div[3]/div[2]/ul/span/li")); Actions action = new Actions

我在IE中使用webdriver代码时遇到鼠标悬停的问题,它在Chrome和Firefox中运行良好,但鼠标悬停问题只在IE中出现。我如何解决这个问题?首先关注一个元素,然后点击链接,请看下面的代码

WebElement newbutton = driver.findElement(By.xpath("//html/body/div/span/form[2]/div/div/div[3]/div[2]/ul/span/li"));    
Actions action = new Actions(driver);    
action.moveToElement(newbutton).build().perform();    
WebElement nextButton=driver.findElement(By.xpath(".//*[@id='menuFmId:headerForm:j_id130']/li/span"));

Actions action1 = new Actions(driver);
action1.moveToElement(nextButton).click(nextButton).build().perform();  

我曾经多次遇到过类似的问题,因为我大部分时间都是在IE上工作。这些页面在IE上的表现出人意料。在花了很多时间试图搜索一种传统方法来实现在IE中悬停后,我最终使用了Javascript

public void mouseHoverJScript(WebElement HoverElement) {
        String mouseOverScript = "if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseover');}";
        ((JavascriptExecutor) driver).executeScript(mouseOverScript, HoverElement);
    }

我知道不建议这样做,但至少我解除了封锁,我的工作也完成了。

请发布HTML代码,以便人们更好地了解问题所在,因为您在第一个按钮中使用的是绝对xpath,可能在IE中,它没有检测到,必须查看代码。