Currently I'm using:
<selenium.version>4.0.0-alpha-5</selenium.version>
for Microsoft EDGE browser version 103.0.1264.62 (64 bit) and all my automation scripts are working perfectly . When i'm updating the selenium version with latest one i.e 4.3.0 then scripts are started failing:
INFO: Detected upstream dialect: W3C
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'LHT6626355535', ip: '10.98.11.998', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_261'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [], extensions: []}}], desiredCapabilities=Capabilities {browserName: MicrosoftEdge, ms:edgeOptions: {args: [], extensions: []}}}]
NAME IS :Validate the Member Details Page Header section First Column Data Validation 2022.07.25.14.13.28.png
java.lang.NullPointerException
REGRESSION_MEMBER_DETAILS_SECTION
File created Screenshots\Results
An exception occured while taking screenshot null
Screenshot Captured
at com.optum.taskTracker.ui.stepDefinitions.Hooks.tearDown(Hooks.java:282)
CodePudding user response:
Use the latest Selenium dependency:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.3.0</version>
</dependency>
Additionally ensure that JDK is upgraded to current levels JDK 8u331.
CodePudding user response:
Try folowing:-
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.3.0</version>
</dependency
<!--
https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.2.1</version>
</dependency>
Then try this:-
String browserName = "EDGE";
//String chromeProfilePath = prop.getProperty("ChromeCookies"); //Use cookies
if(browserName.equals("chrome")){
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
//options.addArguments("chrome.switches", "--disable-extensions");
//options.addArguments("user-data-dir=" chromeProfilePath);
//options.addArguments("--headless");
//options.addArguments("--disable-gpu");
options.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
contr0l = new ChromeDriver(options);
}
else if (browserName.equals("Edge")) {
WebDriverManager.edgedriver().setup();
contr0l = new EdgeDriver();
}
else if (browserName.equals("Firefox")) {
WebDriverManager.firefoxdriver().setup();
contr0l = new FirefoxDriver();
}
else if (browserName.equals("Safari")) {
WebDriverManager.safaridriver().setup();
contr0l = new SafariDriver();
}