简体   繁体   中英

How does the sessionID in Selenium webdriver gets different values for each browser instances during parallel execution

I understand Selenium Webdriver is a Interface and all the browser class is implementing this Interface, I also understand Interface variables are by default static and final. When I was reading about parallel execution using TestNG I read that selenium commands are passed to correct browser using session ID and each of the instances have different session IDs. I am confused how is it possible to assign different values to static final session ID variables of Webdriver Interface??

WebDriver interface doesn't contain session information, neither does SearchContext, which WebDriver Extends.

RemoteWebDriver is handling most of the business, it implements WebDriver. ChromeDriver for example extends RemoteWebDriver.

this allows the following:

WebDriver driver = new ChromeDriver();

RemoteWebDriver has-a sessionId you can't get to the sessionId, because its private in RemoteWebDriver.

You want to look for HttpCommandExecutor, RemoteWebStorage and WebStorage, RemoteSessionStorage and SessionStorage.

Best way is to use your IDE. In Eclipse you would right click on the Class and then "open declaration"

In summary, you can instantiate multiple instances of RemoteWebDriver, each with their own sessionId. When you chose to use the WebDriver interface you lose access to methods not described by the interface.

BTW: If you have attempted to use the JavascriptExecutor, you know you have to cast your WebDiver to it. This is because RemoteWebDriver also implements this interface, but you can't access its methods using the WebDriver Interface.

hope this helps...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM