Selen WebDriver: In diesem Code Mein Testfall ist vorbei für eine Test-E-Mail-Konto, aber für den zweiten Test Mail den Code übersprungen, es geht nicht den zweiten Test E-MailSelen WebDriver TestNG mit
package Packet;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class NewTest {
public WebDriver driver;
// = new ChromeDriver();
// System.setProperty("webdriver.chrome.driver","/Users/rohit/Desktop/chromedriver");
public String baseurl = "http://google.com";
@BeforeTest
public void launchbrowser()
{
System.out.println("LaunchBrowser called...");
System.setProperty("webdriver.chrome.driver", "/Users/rohit/Desktop/chromedriver");
driver = new ChromeDriver();
driver.get(baseurl);
}
// *[@id="gmail-sign-in"]//*[@id="gbw"]/div/div/div[1]/div[1]/a
@BeforeMethod
public void Beforemethod() {
System.out.println("Hello Before Method");
}
@Test(priority = 0)
public void GmailTap() {
System.out.println("Test priority 0 called...");
driver.findElement(By.xpath("//*[@id=\"gbw\"]/div/div/div[1]/div[1]/a")).click();
// driver.findElement(By.xpath("//*[@id=\"gmail-sign-in\"]")).click();
System.out.println("hello");
driver.findElement(By.id("Email")).sendKeys("[email protected]");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.HOURS);
// Thread.sleep(8000);
// driver.close();
// findElement(By.cssSelector(""))
driver.findElement(By.name("signIn")).click();
// CharSequence charSequence = new
boolean flag = true;
while (flag) {
try {
driver.findElement(By.name("Passwd")).sendKeys("123456");
System.out.println("Executed");
flag = false;
} catch (Exception e) {
}
}
driver.findElement(By.id("signIn")).click();
driver.findElement(By.xpath("//*[@id=\"gb\"]/div[1]/div[1]/div[2]/div[4]/div[1]/a/span")).click();
driver.findElement(By.xpath("//*[@id=\"gb_71\"]")).click();
}
// _____________
@Test(priority = 1)
public void GmailTap2() {
System.out.println("Test priority 1 called...");
// driver.findElement(By.xpath("//*[@id=\"gbw\"]/div/div/div[1]/div[1]/a")).click();
System.out.println("hello");
driver.findElement(By.id("Email")).sendKeys("[email protected]");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.HOURS);
driver.findElement(By.name("signIn")).click();
boolean flag = true;
while (flag) {
try {
driver.findElement(By.name("Passwd")).sendKeys("123456");
System.out.println("Executed");
flag = false;
} catch (Exception e) {
}
}
driver.findElement(By.id("signIn")).click();
driver.findElement(By.xpath("//*[@id=\"gb\"]/div[1]/div[1]/div[2]/div[4]/div[1]/a/span")).click();
driver.findElement(By.xpath("//*[@id=\"gb_71\"]")).click();
}
// ____________
@AfterMethod
public void aftersignout1() {
driver.findElement(By.xpath("//*[@id=\"account-chooser-link\"]")).click();
driver.findElement(By.xpath("//*[@id=\"account-chooser-add-account\"]")).click();
}
@AfterTest
public void aftersignout() {
System.out.println("aftersignOut called...");
// New Accnt
driver.close();
}
// *[@id="account-chooser-add-account"]
}
Die Ausgabe wird angezeigt als:
LaunchBrowser called...
Starting ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b) on port 25912
Only local connections are allowed.
Hello Before Method
Test priority 0 called...
hello
Executed
Hello Before Method
Test priority 1 called...
[340.657][SEVERE]: Unable to receive message from renderer
warum u initiieren und ur WebDriver Instanz für jeden Testfall immer wieder zu zerstören ... versuchen, in der @ BeforeTest-Annotation einmal initiieren und es bei @ AfterTest Annotation – noor
@Noor zerstören, habe ich meinen Code durch Ihre Erklärung aktualisiert, aber es gibt mir einen Fehler, der keine Nachricht von Renderer erhalten kann.Kann bitte einen Blick auf meine Code –