java - TestNG test skips while executing it inside servlet -


i trying execute testng test inside servlet of "testlisteneradapter" , "testng" code snippet this:

testlisteneradapter tla = new testlisteneradapter(); testng testng = new testng(); testng.settestclasses(new class[] {src.scriptdemo.logintest.class}); testng.addlistener(tla); testng.run(); 

so, when executing code snippet inside java program test name "logintest" executing (i.e. test starts, browsers opens , whole test executes). when same code runs inside servlet gives:

[testng] running:   command line suite   =============================================== command line suite total tests run: 1, failures: 0, skips: 1 configuration failures: 1, skips: 1 =============================================== 

it seems test starts execute skipped. don't know reason behind this.

ps: debug code , found that, skips test due firefoxdriver() in logintest selenium script file. code of logintest.java is:

package src.scriptdemo;  import org.openqa.selenium.by; import org.openqa.selenium.webdriver; import org.openqa.selenium.firefox.firefoxdriver; import org.testng.annotations.aftertest; import org.testng.annotations.beforetest; import org.testng.annotations.test;  public class logintest {      webdriver driver;     string baseurl;     @beforetest     public void setupselenium() {         driver = new firefoxdriver(true);         baseurl = "https://example.com/login";         system.out.println("1:");     }      @test     public void testcsrlogin() {         driver.get(baseurl);         system.out.println("2:");         driver.findelement(by.id("username")).sendkeys("blah");         driver.findelement(by.id("password")).sendkeys("blah");         driver.findelement(by.classname("btn-primary")).click();     }      @aftertest     public void closeselenium() {             system.out.println("3:");             driver.close();             driver.quit();     } } 

but while executing again commenting firefoxdriver(), test runs without problem , gives output

total tests run: 1, failures: 1, skips: 0 

can suggest whats going on here , how solve it, please let me know if more description required.

thanks in advance

if run them inside container, should make use of selenium grid.(i.e, have create remotewebdriver instance rather browser specific instance).to started selenium grid please visit this link. make sure selenium , grid dependency added , packaged in war.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -