selenium webdriver - Method created in 2nd class skipped while running 2 classes in Testng using xml -


i had created 2 classes having 3 methods/test in these 2 classes. 2 methods/test in 1st class , 3rd method/test in 2nd class. when run these using xml 1st class runs both tests , tests pass method/test in 2nd class skips.

xml:

<?xml version="1.0" encoding="utf-8"?> <suite name= "expedia call tracker">     <test name="expedia home smoke testcases">         <classes>             <class name="expediacalltracker.expedia"/>             <class name="expediacalltracker.expediacreatesale" />         </classes>     </test> </suite>  first class :  package expediacalltracker;  import java.util.concurrent.timeunit; import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement; import org.openqa.selenium.firefox.firefoxdriver; import org.openqa.selenium.support.ui.select; import org.testng.annotations.test;  public class expedia {  public string e;  webdriver expedia = new firefoxdriver();   @test(priority=1)  public void expedialogin() {      expedia.manage().window().maximize();     expedia.get("http://fedev.teleperformanceusa.com/expedia/expediacalltracker/account/login");      expedia.findelement(by.id("username")).sendkeys("kochhar.5");     expedia.findelement(by.id("password")).sendkeys("password11");     expedia.findelement(by.xpath(".//*[@id='loginform']/form/fieldset/p/input")).click();  }   @test(priority=2) public void expediadashsale()  {      expedia.findelement(by.linktext("sale - hww/ean")).click(); } 

}

second class :  package expediacalltracker;  import java.util.concurrent.timeunit;  import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.webelement;  import org.openqa.selenium.support.ui.select; import org.testng.annotations.optional; import org.testng.annotations.parameters; import org.testng.annotations.test;   public class expediacreatesale {  private static final webdriver d = null;  public expediacreatesale() {  }  webdriver expedia = d;            @test public void expediacreate(webdriver d) {       expedia.manage().timeouts().implicitlywait(10, timeunit.seconds);      select lineofbusiness = new select(expedia.findelement(by.id("lineofbusiness")));     lineofbusiness.selectbyindex(1);     expedia.findelement(by.id("sourcecode")).sendkeys("abcdefgh");      webelement upsell = expedia.findelement(by.xpath("html/body/div[1]/section[2]/form/fieldset/div[6]/input[1]"));     upsell.click();      webelement salecall =expedia.findelement(by.xpath("html/body/div[1]/section[2]/form/fieldset/div[8]/input[1]"));     salecall.click();      expedia.findelement(by.id("checkindate")).sendkeys("09/14/2016");      select numberofnights = new select(expedia.findelement(by.id("numberofnights")));     numberofnights.selectbyindex(1);      webelement paymentmethod = expedia.findelement(by.xpath("html/body/div[1]/section[2]/form/fieldset/div[9]/div[6]/input[1]"));     paymentmethod.click();      select currency = new select(expedia.findelement(by.id("currency")));     currency.selectbyindex(70);     expedia.findelement(by.id("grossbooking")).sendkeys("123456");     expedia.findelement(by.id("itinerarynumber")).sendkeys("123456789");     expedia.findelement(by.id("remark")).sendkeys("itinery       number         saved.");     expedia.findelement(by.xpath(".//*[@id='body']/section[2]    /form/fieldset/p/input[1]")).click(); } 

}

can suggest should try ?

test method expediacreate takes parameter webdriver causing issue. fix this, follow same approach expedia class , should work.

moreover, have not initialized webdriver instance variable d in expediacreatesale class. once initialize driver instance, available in test methods dont have pass paramater.

you dont have have line of code also.

private static final webdriver d = null; 

hope helps.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -