Selenium WebDriver automation tool is mainly useful to run tests against multiple Browsers such as Chrome Browser,Firefox Browser,Internet Explorer Driver.Running the tests against multiple browsers is known as Cross Browser Testing.
To launch the Browser in Selenium WebDriver we need to set the path of the executable available in the laptop. Following that we have to instantiate the driver instance based on the Driver instance. In order to avoid these steps we can use the WebDriverManager class.
WebDriverManager
WebDriverManager allows to automate the management of the binary drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver.
Using WebDriverManager its not required to maintain the below lines of the code for launching the browser.
System.setProperty(“webdriver.chrome.driver”, “/path/to/binary/chromedriver”);
System.setProperty(“webdriver.gecko.driver”, “/path/to/binary/geckodriver”);
System.setProperty(“webdriver.opera.driver”, “/path/to/binary/operadriver”);
System.setProperty(“phantomjs.binary.path”, “/path/to/binary/phantomjs”);
System.setProperty(“webdriver.edge.driver”, “C:/path/to/binary/MicrosoftWebDriver.exe”);
System.setProperty(“webdriver.ie.driver”, “C:/path/to/binary/IEDriverServer.exe”);
WebDriverManager Maven Depdendency
To use the WebDriverManager class ensure the following depedency is added in the maven project object model (pom.xml) file.
1 2 3 4 5 |
<dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>3.2.0</version> </dependency> |
Like our Facebook Page to get frequent updates->
https://www.facebook.com/totalqa
Selenium WebDriver Code
Execute the below code in eclipse and verify the results.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.Assert; import org.testng.annotations.Test; import io.github.bonigarcia.wdm.WebDriverManager; public class GoogleTests { @Test public void verifyTitle() { WebDriverManager.chromedriver().setup(); WebDriver driver = new ChromeDriver(); driver.get("http://www.total-qa.com"); String actual = driver.getTitle(); String expected="Total-QA - Future of Software Testing"; Assert.assertEquals(actual,expected); } } |
I have added a WebDriverManager jar file into my project and i have modified the code but wen i run my pom.xml file
i am getting an error “org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
null” could pls help me in solving this issue?
org.apache.maven.plugins
maven-surefire-plugin
3.0.0-M3
Can you try to do this configuration in the pom.xml
org.apache.maven.plugins
maven-surefire-plugin
false
Yes done still same issue
I used this line inside configuration tag
testFailureIgnore> false
I tried doing that but still i am getting same error.