Discussion:
[testng-users] Selenium and TestNG related issue
Dhananjay Bhagwat
2018-09-27 17:49:46 UTC
Permalink
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!!!
--
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.
akash kansal
2018-10-01 03:51:17 UTC
Permalink
Hi ,

What is there in the extended class.
Share the complete code


On Fri, Sep 28, 2018 at 12:30 PM Dhananjay Bhagwat <
Post by Dhananjay Bhagwat
In a class, I have 4 methods. I am calling one method from another class
using extends keyword.
Sometimes it "skips" some test methods and sometimes throws "configuration
called again and again after the whole code runs.
Total tests run: 3, Failures: 0, Skips: 2
Configuration Failures: 1, Skips: 1
===============================================
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);
Thread.sleep(2000);
WebElement checkbox =
for(int i=0; i<1; i++)
{
checkbox.click();
System.out.println(checkbox.isSelected());
}
Thread.sleep(2000);
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);
}
}
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
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.
Dhananjay Bhagwat
2018-10-01 12:43:05 UTC
Permalink
Hi,

In the extended class, there is only one function that automates the
browser or creates a session and opens the browser. Well I tried setting
priority (1.2.3 .... ) before calling the methods/test cases and it solved
my problem.

Now, one more concern, We have a scenario in which there is a "Remember me"
checkbox. When we are logging in for the first time using the script, it
enters the user id and password and clicks on "Remember me" option. Now we
want to check is there any way ask the browser to remember the password and
userid so that next time when we run the script, it should login directly
apart from entering the credentials again?
Post by akash kansal
Hi ,
What is there in the extended class.
Share the complete code
On Fri, Sep 28, 2018 at 12:30 PM Dhananjay Bhagwat <
Post by Dhananjay Bhagwat
In a class, I have 4 methods. I am calling one method from another class
using extends keyword.
annotation. Sometimes it "skips" some test methods and sometimes throws
is getting called again and again after the whole code runs.
Total tests run: 3, Failures: 0, Skips: 2
Configuration Failures: 1, Skips: 1
===============================================
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);
Thread.sleep(2000);
WebElement checkbox =
for(int i=0; i<1; i++)
{
checkbox.click();
System.out.println(checkbox.isSelected());
}
Thread.sleep(2000);
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);
}
}
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
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
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--
*Thanks & Regards,*
*Dhananjay Bhagwat*
--
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.
Loading...