Hi my JUnit test passes in eclipse. JUnit has all green bars in eclipse however when I envoke the xml file from Jenkins it says failed. I have seared for hours on stakeoverflow and i cant find the issue. Please help my code that works is below:
@FixMethodOrder(MethodSorters.NAME_ASCENDING) // this allows you to execute test in order
public class AdpPortal_1_Homepage {
private WebDriver driver;
private String homeUrl;
private String homeTitle = "ADP Associate Portal";
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\eclipse\\chromedriver\\chromedriver.exe");
driver = new ChromeDriver();
homeUrl = "https://myadp.adpcorp.com/wps/myportal/main/myADP_new";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
//Full test
@Test
public void fullTest() throws Exception {
step01_VerifyHomePage();
}
// Go to Home page and verify title
public void step01_VerifyHomePage() throws Exception {
driver.get(homeUrl);
// homeTitle = "ADP Associate Portal"
driver.getTitle().contains(homeTitle);
Thread.sleep(3000);
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}
Also here is my console output from Jenkins:
Please help.
ant file snippet:
<target name="AdpPortal_1_Homepage">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="AdpPortal_1_Homepage" todir="${junit.output.dir}"/>
<classpath refid="ADP_Automation_(JUnit)_(Jenkins).classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
-------------- NEW ISSUE--------------------------
@Before
public void setUp() throws Exception {
System.setProperty("webdriver.chrome.driver", "C:\\eclipse\\chromedriver\\chromedriver.exe");
driver = new ChromeDriver();
homeUrl = "https://myadp.adpcorp.com/wps/myportal/main/myADP_new";
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get(homeUrl);
}
//Full test
@Test
public void fullTest() throws Exception {
step02_HoverMyWorkSpace();
}
public void step02_HoverMyWorkSpace() throws Exception {
WebDriverWait wait = new WebDriverWait(driver,20000);
wait.until(ExpectedConditions.visibilityOfElementLocated((By.id("DivMyWorkList"))));
if ( driver.findElement(By.id("DivMyWorkList")).isDisplayed()){
System.out.println("DivMyWorkList Visiable");
}else{
System.out.println("DivMyWorkList NOT Visiable");
}
// Assert.assertEquals(true, workspace.isDisplayed());
// Thread.sleep(3000);
}