Winappdriver: why did this occured SessionNOtCreatedException?

Created on 2 Oct 2019  路  2Comments  路  Source: microsoft/WinAppDriver

public class Setup 
{
    public static WindowsDriver ExplorerSession = null;
    public static WindowsDriver<WindowsElement> WindowSession = null;
    public static WebElement Result = null;
    public static ChromeDriver Chrome = null;
    public static Modules modules;
    public static Actions actions ;
    public static Session session;

       @BeforeClass
        public static void setup() {
            try {
                 DesiredCapabilities appCapabilities = new DesiredCapabilities();
                 appCapabilities.setCapability("platformName", "Windows");
                 appCapabilities.setCapability("deviceName", "WindowsPC");
                 appCapabilities.setCapability("app", "Root");
                 WindowSession = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4723/wd/hub"), appCapabilities);                
                actions = new Actions(WindowSession);
                modules = new Modules(WindowSession);
                session = new Session(WindowSession);

            }catch(Exception e){
                e.printStackTrace();
            } finally {
            }
        }


        @AfterClass
        public static void TearDown()
        {
            Result = null;
            if (WindowSession != null) {
                WindowSession.quit();
            }
            WindowSession = null;
        }
}

error
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=Root, platformName=Windows, deviceName=WindowsPC}], required capabilities = Capabilities [{}]
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'

console log

{"desiredCapabilities":{"app":"Root","platformName":"Windows","deviceName":"WindowsPC"},"requiredCapabilities":{}}
HTTP/1.1 404 Not Found

error line code is

WindowSession = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4723/wd/hub"), appCapabilities);

what happened?
Isn't there only one session(new URL("http://127.0.0.1:4723/wd/hub") that can be created?

Separately, this code worked normally.

public class Setup 
{
    public static WindowsDriver ExplorerSession = null;
    public static WebElement ExplorerResult = null;
    public static ChromeDriver Chrome = null;
    public static Modules modules;
    public static Actions actions ;
       @BeforeClass
        public static void setup() {
            try {
                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability("app", "C:\\Windows\\explorer.exe");
                ExplorerSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);
                ExplorerSession.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
                actions = new Actions(ExplorerSession);
                modules = new Modules(ExplorerSession);
            }catch(Exception e){
                e.printStackTrace();
            } finally {
            }
        }


        @AfterClass
        public static void TearDown()
        {
            ExplorerResult = null;
            if (ExplorerSession != null) {
                ExplorerSession.quit();
            }
            ExplorerSession = null;
        }
}

Most helpful comment

I guess your URL in Java doesn't match the command you launch WinAppDriver.
Typically there three ways to start WinAppDriver, you may cd C:\Program Files (x86)\Windows Application Driver, then

  • WinAppDriver.exe 4727
  • WinAppDriver.exe 127.0.0.1 4725
  • WinAppDriver.exe 127.0.0.1 4723/wd/hub

By default, it's 127.0.0.1:4723, so you need to use new URL("http://127.0.0.1:4723") in Java.
wd/hub is specific to the connection with Appium, and I don't expect you to use it unless your solution is Java WebDriver + Appium + WinAppDriver.

If you launched WinAppDriver with WinAppDriver.exe 127.0.0.1 4723/wd/hub, your URL should be new URL("http://127.0.0.1:4723/wd/hub") too.

WebDriver + Appium + WinAppDriver is a little different, and you should launch WinAppDriver with /wd/hub, but new URL without /wd/hub

I didn't do the testing, but I guess WinAppDriver supports multiple sessions. Because 'keyboard/mouse focus' problem, multiple session should be controlled in on test case and it doesn't support two test cases are running at the same time.

All 2 comments

I guess your URL in Java doesn't match the command you launch WinAppDriver.
Typically there three ways to start WinAppDriver, you may cd C:\Program Files (x86)\Windows Application Driver, then

  • WinAppDriver.exe 4727
  • WinAppDriver.exe 127.0.0.1 4725
  • WinAppDriver.exe 127.0.0.1 4723/wd/hub

By default, it's 127.0.0.1:4723, so you need to use new URL("http://127.0.0.1:4723") in Java.
wd/hub is specific to the connection with Appium, and I don't expect you to use it unless your solution is Java WebDriver + Appium + WinAppDriver.

If you launched WinAppDriver with WinAppDriver.exe 127.0.0.1 4723/wd/hub, your URL should be new URL("http://127.0.0.1:4723/wd/hub") too.

WebDriver + Appium + WinAppDriver is a little different, and you should launch WinAppDriver with /wd/hub, but new URL without /wd/hub

I didn't do the testing, but I guess WinAppDriver supports multiple sessions. Because 'keyboard/mouse focus' problem, multiple session should be controlled in on test case and it doesn't support two test cases are running at the same time.

I guess your URL in Java doesn't match the command you launch WinAppDriver.
Typically there three ways to start WinAppDriver, you may cd C:\Program Files (x86)\Windows Application Driver, then

  • WinAppDriver.exe 4727
  • WinAppDriver.exe 127.0.0.1 4725
  • WinAppDriver.exe 127.0.0.1 4723/wd/hub

By default, it's 127.0.0.1:4723, so you need to use new URL("http://127.0.0.1:4723") in Java.
wd/hub is specific to the connection with Appium, and I don't expect you to use it unless your solution is Java WebDriver + Appium + WinAppDriver.

If you launched WinAppDriver with WinAppDriver.exe 127.0.0.1 4723/wd/hub, your URL should be new URL("http://127.0.0.1:4723/wd/hub") too.

WebDriver + Appium + WinAppDriver is a little different, and you should launch WinAppDriver with /wd/hub, but new URL without /wd/hub

I didn't do the testing, but I guess WinAppDriver supports multiple sessions. Because 'keyboard/mouse focus' problem, multiple session should be controlled in on test case and it doesn't support two test cases are running at the same time.

I tried to this URL("http://127.0.0.1:4723"). so operate normally
so now I can try to other work. you save my day!!

Was this page helpful?
0 / 5 - 0 ratings