Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
2.3k views
by The go-to Tester (218 points)
edited by

I have written an automated test using Selenium Webdriver. I have used Action class to perform mouse hover action. My code is-:

 

public class MouseOverDemo {
    WebDriver driver;
    @Test
    public void testMouseOver() throws Exception
    {
        driver.get("https://www.policybazaar.com/");
        assertEquals("Insurance - Compare Insurance Policy Quotes - Life, Car, Health, Travel",driver.getTitle());
        Actions a=new Actions(driver);
        a.moveToElement(driver.findElement(By.xpath("//div[@id='navbar']/ul[2]/li[1]/a")));
        driver.findElement(By.linkText("Child Plans")).click();
        Thread.sleep(4000);
    }
    @BeforeMethod
    public void setUp()
    {
        System.setProperty("webdriver.gecko.driver", "C://Selenium driver/geckodriver.exe");
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities.setCapability("marionette", true);
        driver=new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
    }
    @AfterMethod
    public void tearDown()
    {
        driver.quit();
    }


 

The error that I get is
 

FAILED: testMouseOver
org.openqa.selenium.WebDriverException: An unknown error has occurred
Build info: version: 'unknown', revision: 'b526bd5', time: '2017-03-07 11:11:07 -0800'
System info: host: 'HOME-PC', ip: '192.168.0.11', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, appBuildId=20170125094131, version=51.0.1, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=6132, browserVersion=51.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}]
Session ID: ecd9c5ed-89ea-4196-b96c-5b834c2cfdd8
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
    at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:670)
    at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:634)
    at org.openqa.selenium.interactions.Actions.perform(Actions.java:596)
    at AllScripts.MouseOverDemo.testMouseOver(MouseOverDemo.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:823)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
    at org.testng.TestRunner.privateRun(TestRunner.java:778)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
    at org.testng.SuiteRunner.run(SuiteRunner.java:268)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1225)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1150)
    at org.testng.TestNG.runSuites(TestNG.java:1075)
    at org.testng.TestNG.run(TestNG.java:1047)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)

===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


 

Please Help!

2 Answers

0 like 0 dislike
by The go-to Tester (181 points)

For Firefox version 47 and above, you should start using Marionette driver.

You can download Marionette driver from here, https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver

Once you downloaded Marionette driver, you can use it as below.

String currentDir = System.getProperty("user.dir");
String marionetteDriverLocation = currentDir + "/tools/marionette/wires.exe";
System.setProperty("webdriver.gecko.driver", marionetteDriverLocation);
WebDriver driver = new MarionetteDriver();
0 like 0 dislike
by The go-to Tester (115 points)
After downloading and changing the reference of Marionette driver, if still mouseover didnt work, you can try build.perform

a.click().build().perform();


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...