我已经为我的Selenium webDriver套件创建了一个可运行的jar . 现在我必须在多个基本URL中测试它,因为baseURl将根据需要进行更改 . 有人可以指导我完成这件事 . 是否可以将命令行参数发送到Selenium Web Driver driver.get(baseUrl)
我写的这段代码但它不起作用 .
公共课新闻{
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver();
try{
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("var pr=prompt('Enter your URL please:',''); alert(pr);");
Thread.sleep(15000L);
String URL = driver.switchTo().alert().getText();
driver.switchTo().alert().accept();
System.out.println(URL);
driver.get(URL);
System.out.println(URL);
}catch(Throwable e)
{
System.out.println("failed");
}
driver.manage().window().maximize();
WebElement login=driver.findElement(By.cssSelector("a[data-target='#login-box']"));
login.click();
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.findElement(By.id("uname_h")).sendKeys("Abc@gmail.com");
driver.findElement(By.id("password_h")).sendKeys("XYZ");
WebElement login_button=driver.findElement(By.id("health_btn"));
login_button.click();
// driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.findElement(By.className("glyphicon-publish-news-events")).click();
driver.findElement(By.xpath("/html/body/div[4]/div[4]/div[26]/div/ul/li[2]/a")).click();
driver.findElement(By.id("newstitle")).sendKeys("Automation testing news");
driver.findElement(By.id("newsdetails")).sendKeys("Automation testing news datails");
WebElement webElement13 = driver.findElement(By.id("s2id_autogen3"));
webElement13.sendKeys("ganesh");
webElement13.sendKeys(Keys.ENTER);
}}