Selenium webdriver 如何在SeleniumWebDriver中使用唯一的应用程序号来运行多个浏览器(如chrome、firefox)来注册学生

Selenium webdriver 如何在SeleniumWebDriver中使用唯一的应用程序号来运行多个浏览器(如chrome、firefox)来注册学生,selenium-webdriver,testng,Selenium Webdriver,Testng,场景:唯一的应用程序编号(Zee1106),用于注册学生并为多个浏览器(并行)运行testng,如selenium webdriver中的chrome、firefox 在上面的场景中,我已经运行了测试套件,第一个浏览器(chrome)成功注册,下一个浏览器(firefox)未注册。因为已经登记的警报即将到来。在这个场景中,我如何在webdriver中使用多个浏览器的唯一应用程序编号注册学生 谢谢, Vairamuthu实现这一点的方法有很多。一种最简单的方法是将“应用程序编号”作为逗号分隔的值存

场景:唯一的应用程序编号(Zee1106),用于注册学生并为多个浏览器(并行)运行testng,如selenium webdriver中的chrome、firefox

在上面的场景中,我已经运行了测试套件,第一个浏览器(chrome)成功注册,下一个浏览器(firefox)未注册。因为已经登记的警报即将到来。在这个场景中,我如何在webdriver中使用多个浏览器的唯一应用程序编号注册学生

谢谢,
Vairamuthu

实现这一点的方法有很多。一种最简单的方法是将“应用程序编号”作为逗号分隔的值存储在测试数据表中,并将每个值用于相应的浏览器。例如:

  //Assume applicationNo is stored as a comma separated value in test data. Something like this

    String applicationNo="zee1106, zee1107, zee1108"; //please read these data from test data sheet
    String[] unquieAppNo=applicationNo.split(",");

    //get the browserName
    Capabilities caps = ((RemoteWebDriver) driver).getCapabilities();
    String browserName = caps.getBrowserName();

    //if the browser name is chrome then use one of the application id and so on for each browser.
    if(browserName.equalsIgnoreCase("chrome")){
        driver.findElement(By.id("<employee app number>")).sendKeys(unquieAppNo[0]);
    }else if (browserName.equalsIgnoreCase("firefox")) {
        driver.findElement(By.id("<employee app number>")).sendKeys(unquieAppNo[1]);
    }else{ //any other browser
        driver.findElement(By.id("<employee app number>")).sendKeys(unquieAppNo[2]);
    }
//假设applicationNo在测试数据中存储为逗号分隔的值。像这样的
字符串applicationNo=“zee1106、zee1107、zee1108”//请从测试数据表中读取这些数据
字符串[]unquieAppNo=applicationNo.split(“,”);
//获取浏览器名称
能力上限=((RemoteWebDriver)驱动程序).getCapabilities();
字符串browserName=caps.getBrowserName();
//如果浏览器名称为chrome,则为每个浏览器使用一个应用程序id,依此类推。
if(浏览器名称.相等信号案例(“chrome”)){
driver.findElement(By.id(“”).sendKeys(unquieAppNo[0]);
}else if(browserName.equalsIgnoreCase(“firefox”)){
driver.findElement(By.id(“”).sendKeys(unquieAppNo[1]);
}else{//任何其他浏览器
driver.findElement(By.id(“”).sendKeys(unquieAppNo[2]);
}

如果根本没有发布代码,很难判断。您正在使用哪种语言?请发布您实例化Webdriver的方式。根据您的描述,我猜您正在使用类似以下内容(静态):

虽然您每次都需要一个不同的WebDriver实例:

 public WebDriver  driver;
 public WebDriver  driver;