While automating I open several browsers, say Firefox, with
driver1 = webdriver.Firefox()
driver2 = webdriver.Firefox()
driver3 = webdriver.Firefox()
.....
Is there a way to get the session_id
and webdriver itself of the active Browser?
The same question for Appium. Is it possible to get session_id
and driver itself of the active device (virtual or real)?
Is it possible to use appium and selenium together in one test case? yes you can, no need to switch the context, use the web/mobile driver as your test case flow goes.
Mastering XPath and CSS Selector for SeleniumWe can interact with an existing browser session. This is performed by using the Capabilities and ChromeOptions classes. The Capabilities class obtains the browser capabilities with the help of the getCapabilities method.
Just like you might open web pages in different tabs locally, it's also possible to have multiple tabs up in one browser during a Selenium test.
To get the driver session id with Selenium / Java:
WebDriver driver = new FirefoxDriver();
SessionId session = ((FirefoxDriver)driver).getSessionId();
System.out.println("Session id: " + session.toString());
To get the remote driver session id with Selenium / Java:
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4722/wd/hub"), capabilities);
SessionId session = ((RemoteWebDriver)driver).getSessionId();
System.out.println("Session id: " + session.toString());
((ChromeDriver)driver).sessionId();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With