如何使用Selenium WebDriver打开新标签?
我想在新标签中打开多个链接.这是为了尽快完成构建验证任务.因此,在每个新标签中,可以打开所有与烟雾测试相关的链接,然后在每个对应于烟雾测试要求的标签内,我们可以进行健全性测试.
如果我的计算机在我不在的情况下进入睡眠模式/休眠模式,我的执行中的selenium脚本会停止吗?如果是的话,那么摆脱这个的理想方法是什么?
package erewards2;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class login_sib2 {
public static void main(String[] args) {
FirefoxDriver d1 = new FirefoxDriver();
d1.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
d1.get("https://sib3.erewardsredeem.com/fm/customer.html?action=userLogin");
d1.manage().window().maximize();
WebElement e4 = d1.findElementByLinkText("Login");
e4.click();
d1.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement e1 = d1.findElement(By.id("showmemberid"));
e1.sendKeys("2800000091");
WebElement e2 = d1.findElementById("showmemberpwd");
e2.sendKeys("Miquser1");
WebElement e3 = d1.findElementByClassName("loginbtn");
e3.click();
WebElement e5 = d1.findElementByLinkText("Logout");
e5.click();
Alert a1 = d1.switchTo().alert(); //web based alert
WebDriverWait wait = new WebDriverWait(d1,10);
wait.until(ExpectedConditions.alertIsPresent()).accept();
a1.accept();
System.out.println("test1");
//close Firefox
d1.close(); …Run Code Online (Sandbox Code Playgroud)