[英]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. 我理解Selenium Webdriver是一个接口,所有的浏览器类都在实现这个接口,我也理解接口变量默认是静态的和最终的。 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.
当我阅读使用TestNG的并行执行时,我读到使用会话ID将selenium命令传递给正确的浏览器,并且每个实例都有不同的会话ID。 I am confused how is it possible to assign different values to static final session ID variables of Webdriver Interface??
我很困惑如何为Webdriver接口的静态最终会话ID变量分配不同的值?
WebDriver interface doesn't contain session information, neither does SearchContext, which WebDriver Extends. WebDriver接口不包含会话信息,SearchContext也不包含WebDriver扩展。
RemoteWebDriver is handling most of the business, it implements WebDriver. RemoteWebDriver正在处理大部分业务,它实现了WebDriver。 ChromeDriver for example extends RemoteWebDriver.
ChromeDriver例如扩展了RemoteWebDriver。
this allows the following: 这允许以下内容:
WebDriver driver = new ChromeDriver(); WebDriver driver = new ChromeDriver();
RemoteWebDriver has-a sessionId you can't get to the sessionId, because its private in RemoteWebDriver. RemoteWebDriver有一个sessionId,你无法访问sessionId,因为它在RemoteWebDriver中是私有的。
You want to look for HttpCommandExecutor, RemoteWebStorage and WebStorage, RemoteSessionStorage and SessionStorage. 您想要查找HttpCommandExecutor,RemoteWebStorage和WebStorage,RemoteSessionStorage和SessionStorage。
Best way is to use your IDE. 最好的方法是使用您的IDE。 In Eclipse you would right click on the Class and then "open declaration"
在Eclipse中,您可以右键单击Class然后“打开声明”
In summary, you can instantiate multiple instances of RemoteWebDriver, each with their own sessionId. 总之,您可以实例化RemoteWebDriver的多个实例,每个实例都有自己的sessionId。 When you chose to use the WebDriver interface you lose access to methods not described by the interface.
当您选择使用WebDriver接口时,您将无法访问界面未描述的方法。
BTW: If you have attempted to use the JavascriptExecutor, you know you have to cast your WebDiver to it. 顺便说一句:如果你试图使用JavascriptExecutor,你知道你必须将你的WebDiver投射到它。 This is because RemoteWebDriver also implements this interface, but you can't access its methods using the WebDriver Interface.
这是因为RemoteWebDriver也实现了此接口,但您无法使用WebDriver接口访问其方法。
hope this helps... 希望这可以帮助...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.