What is the mechinism used for commiunication between webdriver and browser

余生颓废 提交于 2019-12-22 09:47:55

问题


Anyone can explain how communication happen between browser and web-driver?. How does webdriver object read and identify html elements in browser ?. For that what is the relationship between webdriver object and browser and how to build the relationship browser and webdriver object?

 driver = new FirefoxDriver(); 
 driver.findElements(By.id("element")); 

回答1:


The communication between webdriver and browser happens through a json-wire protocol which is specified in the W3C documentation. All browsers that webdriver supports, uses this same protocol.

How does webdriver read and identify elements in a page? This varies from browser to browser.

Firefox - webdriver gets installed as a plugin in your browser while running the test. The webdriver server will send the json-commands to this plugin and those commands will get executed in the browser. The plugin is built within the webdriver jar file. It will get installed while running the test.

Chrome - For testing chrome, you would also need a chromedriver.exe file. This chromedriver.exe acts similar to the firefox plugin. It can receive the commands from webdriver server and execute it on the browser

IE - Similar to Chrome, IE executes with the help of InternetExplorerDriver.exe.

You can understand more about the functioning by looking at the different DriverFile source code in github.

You can also get an understanding about the working from here - http://www.aosabook.org/en/selenium.html. I am not sure how updated this page is, but should help to understand the concept.



来源:https://stackoverflow.com/questions/31822790/what-is-the-mechinism-used-for-commiunication-between-webdriver-and-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!