[英]Change Between Chrome and Firefox per Scenario in Selenium Java ( CUCUMBER , JUnit)
How can i change between browsers when i run a specific scenario in Java? 在Java中运行特定方案时,如何在浏览器之间进行切换?
I already imported the 2 browsers so far i can only open both of them using the code 到目前为止,我已经导入了2个浏览器,我只能使用代码打开两个浏览器
public void accessURL() throws Throwable
{
Registration_Steps_1.setUp();
for(String browser : browserDriver)
{
driver=Registration_Steps_1.initiateBrowserDriver(browser);
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(baseUrl);
super.driver = driver;
}
}
after that i cannot run the other methods for each of the browsers 之后,我无法为每个浏览器运行其他方法
Do you want to run test on both browser if yes, user testng suite and pass browser parameter from testng suite. 如果要,是否要在两个浏览器上运行测试,请使用用户testng套件并从testng套件传递浏览器参数。
Second approach setup browser type in configuration file read from there and run test on browser as mention in configuration file. 第二种方法是在从配置文件中读取的配置文件中设置浏览器类型,然后在浏览器上运行测试。
the next methods might probably be running by the second browser coming from your browserDriver. 接下来的方法可能由来自browserDriver的第二个浏览器运行。
driver object will be a fresh instance of webdriver interface and will not have any session. 驱动程序对象将是webdriver接口的新实例,并且将没有任何会话。
so, if you want to run a flow involving login with two browsers, it will not be possible as the login session will recorded in the browser with which you logged in. 因此,如果您要运行一个涉及使用两个浏览器登录的流程,将无法进行,因为登录会话将记录在您登录所用的浏览器中。
if it is a general url traversing stuff you can do with two browsers by calling the second browser by instantiating the driver object again in the middle. 如果它是一般的url遍历内容,则可以通过在中间再次实例化驱动程序对象来调用第二个浏览器,从而对两个浏览器进行处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.