Error while working with testNG | Selenium Forum
R
Rupa 4 days go

package demoQA;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class RadioButton {

static WebDriver driver;

@BeforeTest

public void openDemoQA(){

driver=new ChromeDriver();
driver.get("http://thedemosite.co.uk/login.php");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}

@BeforeClass

public void openDemo(){
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://demoqa.com/");
}
@AfterTest

public void closeDemoQA(){

driver.quit();
}

@Test
public void login(){

driver.findElement(By.name("username")).sendKeys("daskhatri");
driver.findElement(By.name("password")).sendKeys("daskhatr");
driver.findElement(By.name("FormsButton2")).click();
System.out.println(driver.getTitle());
}

@Test

public void textBox(){

WebDriverWait wait=new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfAllElements(driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]"))));
driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]")).click();
driver.findElement(By.xpath("//div[@class='element-group']/div/ul/li[1]")).click();
driver.findElement(By.id("userName")).sendKeys("rupa");
driver.findElement(By.id("userEmail")).sendKeys("rupaguzar@gmail.com");
driver.findElement(By.id("currentAddress")).sendKeys("Mysore");
driver.findElement(By.id("permanentAddress")).sendKeys("Nandikotkur");
System.out.println(driver.getTitle());
driver.navigate().back();
}

@Test

public void checkBox(){

WebDriverWait wait=new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfAllElements(driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]"))));
driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]")).click();
driver.findElement(By.xpath("//div[@class='element-group']/div/ul/li[2]")).click();
System.out.println(driver.getTitle());
driver.findElement(By.xpath("//span[@class='rct-checkbox']")).click();
System.out.println(driver.getTitle());
driver.navigate().back();
}

@Test

public void radioButton(){

WebDriverWait wait=new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfAllElements(driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]"))));
driver.findElement(By.xpath("//div[@class='home-content']/div[2]/div/div[1]")).click();
driver.findElement(By.xpath("//div[@class='element-group']/div/ul/li[3]")).click();
driver.findElement(By.xpath("//label[@class='custom-control-label'][contains(text(),'Impressive')]")).click();
System.out.println(driver.getTitle());
driver.navigate().back();

}


}


A
Ashish 3 days ago

What is the error which you are getting

You can also paste the screenshot of the error out here


Related Posts