Running multiple browser instances in the same test spec

◇◆丶佛笑我妖孽 提交于 2019-12-06 10:06:26

This is a really interesting question that is not covered in Using Multiple Browsers in the Same Test or in the interaction_spec.js.

The problem with page objects is that page object fields are usually defined with a globally available element or browser which in your case would always point to the first browser instance. But you basically need to call element() using a specific browser:

b2.element(by.id('searchInput'));

instead of just:

element(by.id('searchInput'));

FYI, element is just a shortcut for browser.element.


I am really not sure whether this is a reliable solution and would actually work, but you can redefine global element this way. Think about it as switching the search context to different browser instances:

SearchPage.searchButton.click();

global.element = b2.element;
SearchPage.searchButton.click();

global.element = b3.element;
SearchPage.searchButton.click();

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