Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97774

Inheritance in selenium webdriver using testng

$
0
0
package user;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.openqa.selenium.chrome.ChromeDriver;import org.testng.annotations.Test;import org.testng.annotations.BeforeTest;public class Login {    public WebDriver driver;  @Test  public void Signin() throws Exception   {      driver.manage().window().maximize();      Thread.sleep(5000);      driver.navigate().refresh();      driver.findElement(By.xpath("//div[@id='header']/div/div/ul/li[6]/a")).click();      driver.findElement(By.id("Email")).sendKeys("test@gmail.com");      driver.findElement(By.id("password")).sendKeys("123456");      driver.findElement(By.xpath("//tr[5]/td[2]/input")).click();      Thread.sleep(5000);    }  @BeforeTest  public void BeforeTest() {     System.setProperty("webdriver.chrome.driver", "D:\\lib\\chromedriver.exe");     driver = new ChromeDriver();         driver.get("http://test.com/");  }

INHERITANCE

package user;import org.openqa.selenium.By;import org.openqa.selenium.WebDriver;import org.testng.annotations.Test;public class Addtocart extends Login {    public WebDriver driver;  @Test  public void Cart() throws Exception {      Thread.sleep(5000);      driver.findElement(By.xpath("//div[2]/div/div/a")).click();      driver.findElement(By.xpath("//a[contains(@href, '/Catalog/Featured')]")).click();      driver.findElement(By.id("//div[4]/div/a/img")).click();      driver.findElement(By.id("anchorAddToWishList")).click();*/  } public static void main(String[] args) throws Exception{      Addtocart ac = new Addtocart();      ac.BeforeMethod();          ac.Signin();      ac.Cart();  }}

When i try to call the super class method first. the sub class method is calling first. How to call super class method initially


Viewing all articles
Browse latest Browse all 97774

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>