I am automating hybrid application. Where I have to click on XXX.20.1.4.lnk application which is on my Windows 11 desktop. Once clicked on application, it opens in MS Edge browser. And I have to do execute further test cases on opened MS Edge browser. Below, I haved winium driver to open/click on XXX.20.1.4.lnk application. EdgeOption to use same port of Winium driver to have same driver instance to continue execution on MS Edge browser.
I tried with driver.get("C:\Users\Prashant\Desktop\XXX.20.1.4.lnk"); but blank browser will open only. it will not open application.
Environment Used : Windows 11
MS Edge Browser : 105.0.1343.42
Selenium Version Used: 3.141.59
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeDriverService;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.openqa.selenium.winium.WiniumDriverService;
public class EdgeOpenTest {
public static void main(String[] args) throws InterruptedException {
WiniumDriver windriver;
String applicationPath = "C:\\Users\\Prashant\\Desktop\\172.20.1.4.lnk";
try {
DesktopOptions option = new DesktopOptions();
option.setApplicationPath(applicationPath);
File driverPath = new File(System.getProperty("user.dir") + File.separator + "drivers" + File.separator
+ "Winium.Desktop.Driver.exe");
System.out.println(driverPath);
WiniumDriverService service = new WiniumDriverService.Builder().usingDriverExecutable(driverPath).usingPort(9999).withVerbose(true).withSilent(false).buildDesktopService();
try {
service.start();
} catch (IOException e) {
System.out.println("Exception while starting WINIUM service");
e.printStackTrace();
}
windriver = new WiniumDriver(service, option);
} catch (Exception e) {
System.out.println("Exception Occured :: "+e);
}
Thread.sleep(20000);
System.setProperty("webdriver.edge.driver","D:\\Prashant_Workspace\\ChromeTest\\drivers\\msedgedriver.exe");
ChromeOptions opt=new ChromeOptions();
opt.setExperimentalOption("debuggerAddress","localhost:9999 ");
EdgeOptions options = new EdgeOptions().merge(opt);
WebDriver driver=new EdgeDriver(options);
driver.get("http://facebook.com");
}
}
POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ChromeTest.com</groupId>
<artifactId>ChromeTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-elements-desktop</artifactId>
<version>0.2.0-1</version>
</dependency>
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-webdriver</artifactId>
<version>0.1.0-1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- <dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-beta-4</version>
</dependency> -->
</dependencies>
</project>
Exception Getting :
D:\Prashant_Workspace\ChromeTest\drivers\Winium.Desktop.Driver.exe
Starting Windows Desktop Driver on port 9999
01:15:17 [ERROR] SocketException occurred while trying to start listner: System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at Winium.Desktop.Driver.Listener.StartListening()
01:15:17 [FATAL] Failed to start driver: System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at Winium.Desktop.Driver.Listener.StartListening()
at Winium.Desktop.Driver.Program.Main(String[] args)
Unhandled Exception: System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start(Int32 backlog)
at Winium.Desktop.Driver.Listener.StartListening()
at Winium.Desktop.Driver.Program.Main(String[] args)
Sep 21, 2022 1:15:17 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Starting Microsoft Edge WebDriver 105.0.1343.25 (d3a25e9da89eba5d55f1ab48fced0ccd321e4ba8) on port 28946
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver
Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.
Microsoft Edge WebDriver was started successfully.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: No matching capabilities found
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'QAMACHINE87687686', ip: 'XXX.XX.X.X', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: EdgeDriver
remote stacktrace: Backtrace:
Microsoft::Applications::Events::EventProperties::SetProperty [0x00007FF7967420C2+17554]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7966DE872+1437618]
Ordinal0 [0x00007FF796309345+627525]
Ordinal0 [0x00007FF7963683EB+1016811]
Ordinal0 [0x00007FF796367841+1013825]
Ordinal0 [0x00007FF79636941B+1020955]
Ordinal0 [0x00007FF796363A43+997955]
Ordinal0 [0x00007FF7963394C0+824512]
Ordinal0 [0x00007FF79633A9F8+829944]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7965A0588+134344]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF796589EB5+42485]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF79658CF9C+55004]
Ordinal0 [0x00007FF7963F21B4+1581492]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7966E3FBB+1459963]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7966E7F84+1476292]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7966E80DD+1476637]
Microsoft::Applications::Events::EventProperty::EventProperty [0x00007FF7966F00A9+1509353]
BaseThreadInitThunk [0x00007FF8774454E0+16]
RtlUserThreadStart [0x00007FF87862485B+43]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:130)
at EdgeOpenTest.main(EdgeOpenTest.java:68)
If I use Selenium Version 4.0.0-beta-4, getting below exception:
D:\Prashant_Workspace\ChromeTest\drivers\Winium.Desktop.Driver.exe
Exception in thread "main" java.lang.NoSuchMethodError: 'void org.openqa.selenium.remote.service.DriverService.<init>(java.io.File, int, com.google.common.collect.ImmutableList, com.google.common.collect.ImmutableMap)'
at org.openqa.selenium.winium.WiniumDriverService.<init>(WiniumDriverService.java:114)
at org.openqa.selenium.winium.WiniumDriverService$Builder.buildDesktopService(WiniumDriverService.java:191)
at EdgeOpenTest.main(EdgeOpenTest.java:37)