Dhananjay Bhagwat
2018-09-27 17:49:46 UTC
In a class, I have 4 methods. I am calling one method from another class
using extends keyword.
I am getting issues in calling more than one method with @Test annotation.
Sometimes it "skips" some test methods and sometimes throws "configuration
issue". Also, my one of my method containing @BeforeMethod is getting
called again and again after the whole code runs.
Total tests run: 3, Failures: 0, Skips: 2
Configuration Failures: 1, Skips: 1
===============================================
Here is my code:
package AutomationFramework;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class DashboardCandidateScheduled extends CreateSession{
/*LOGIN TO APTITUDE*/
@BeforeMethod
public void login() throws InterruptedException {
System.out.println("We are logging in to the portal!!!");
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[1]/input")).sendKeys("");
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[2]/input")).sendKeys("");
WebElement checkbox =
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[3]/input"));
for(int i=0; i<1; i++)
{
checkbox.click();
System.out.println(checkbox.isSelected());
}
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[2]/button")).click();
Thread.sleep(2000);
System.out.println("Login Success");
}
/*Candidate Scheduled List*/
@Test(alwaysRun=true)
public void CandidateScheduled() throws InterruptedException {
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div[1]/div[4]/div/a")).click();
Thread.sleep(3000);
/*View number of records in the list*/
Select record = new Select(driver.findElement(By.name("example1_length")));
Thread.sleep(1000);
record.selectByVisibleText("50");
System.out.println("Record Length set to 50 !!!");
}
@Test(alwaysRun=true)
public void ScheduleTest() throws InterruptedException {
System.out.println("Scheduling Test for Candidate!!!");
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div/div/div/div[1]/div/a[3]/button")).click();
Thread.sleep(3000);
driver.navigate().back();
//Thread.sleep(5000);
//driver.close();
}
@Test(alwaysRun=true)
public void HelpAccess() throws InterruptedException {
System.out.println("Accessing help !!!");
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div/div/div/div[1]/div/a[5]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[@id='mySidenav']/div[1]/a")).click();
}
}
Seeking Help!!!
using extends keyword.
I am getting issues in calling more than one method with @Test annotation.
Sometimes it "skips" some test methods and sometimes throws "configuration
issue". Also, my one of my method containing @BeforeMethod is getting
called again and again after the whole code runs.
Total tests run: 3, Failures: 0, Skips: 2
Configuration Failures: 1, Skips: 1
===============================================
Here is my code:
package AutomationFramework;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class DashboardCandidateScheduled extends CreateSession{
/*LOGIN TO APTITUDE*/
@BeforeMethod
public void login() throws InterruptedException {
System.out.println("We are logging in to the portal!!!");
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[1]/input")).sendKeys("");
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[2]/input")).sendKeys("");
WebElement checkbox =
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[1]/div[3]/input"));
for(int i=0; i<1; i++)
{
checkbox.click();
System.out.println(checkbox.isSelected());
}
Thread.sleep(2000);
driver.findElement(By.xpath(".//*[@id='login-box']/form/div[2]/button")).click();
Thread.sleep(2000);
System.out.println("Login Success");
}
/*Candidate Scheduled List*/
@Test(alwaysRun=true)
public void CandidateScheduled() throws InterruptedException {
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div[1]/div[4]/div/a")).click();
Thread.sleep(3000);
/*View number of records in the list*/
Select record = new Select(driver.findElement(By.name("example1_length")));
Thread.sleep(1000);
record.selectByVisibleText("50");
System.out.println("Record Length set to 50 !!!");
}
@Test(alwaysRun=true)
public void ScheduleTest() throws InterruptedException {
System.out.println("Scheduling Test for Candidate!!!");
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div/div/div/div[1]/div/a[3]/button")).click();
Thread.sleep(3000);
driver.navigate().back();
//Thread.sleep(5000);
//driver.close();
}
@Test(alwaysRun=true)
public void HelpAccess() throws InterruptedException {
System.out.println("Accessing help !!!");
driver.findElement(By.xpath("html/body/div[3]/aside[2]/section[2]/div/div/div/div[1]/div/a[5]")).click();
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[@id='mySidenav']/div[1]/a")).click();
}
}
Seeking Help!!!
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+***@googlegroups.com.
To post to this group, send email to testng-***@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.