简体   繁体   English

Selenium webdriver中的sessionID如何在并行执行期间为每个浏览器实例获取不同的值

[英]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.

相关问题 Webdriver 在 Cucumber 中并行执行期间在同一浏览器中输入凭据 - Webdriver enters credentials in same browser during parallel execution in Cucumber WebDriver:如何使用同一浏览器(Firefox)处理并行测试执行? - WebDriver: How to deal with parallel test execution using the same browser (Firefox)? 在Selenium Webdriver中并行执行TestCases捕获屏幕截图 - Capturing Screenshot in Parallel Execution of TestCases in Selenium Webdriver 使用Selenium Webdriver并行测试多个浏览器 - Multiple Browser in parallel test using Selenium Webdriver selenium grid 在同一浏览器上并行执行 - selenium grid parallel execution on the same browser 如何使用Selenium Webdriver以其他用户身份运行firefox浏览器? - How to run firefox browser as a different user with Selenium Webdriver? 使用非静态WebDriver进行并行执行-Selenium-TestNG-Java - Use non-static WebDriver for parallel execution - Selenium - TestNG - Java 如何使用Java绑定并行化Selenium Webdriver实例? - How to parallelize instances of selenium webdriver with java bindings? Selenium Webdriver在执行测试脚本期间非常不一致 - Selenium Webdriver is very inconsistent during Execution of test scripts 如何使用@BeforeSuite批注使用Selenium + TestNG运行多个浏览器会话(并行执行) - How to run multiple browser sessions (parallel execution) with Selenium + TestNG using @BeforeSuite annotation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM