0

I need help.

So I want to make my automation running in jenkins job. I am using appium studio for information. For now my test can run on appium studio and eclipse. But when running build on jenkins I get error below:

enter image description here

My setup:

enter image description here

Build.xml:

enter image description here

Test result:

test result

Code:

package junit;
//package <set your test package>;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.junit.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.logging.Level;

public class junit {
private String reportDirectory = "reports";
private String reportFormat = "xml";
private String testName = "tiket1adult";
protected AndroidDriver<AndroidElement> driver = null;

DesiredCapabilities dc = new DesiredCapabilities();

@Before
public void setUp() throws MalformedURLException {
    dc.setCapability("reportDirectory", reportDirectory);
    dc.setCapability("reportFormat", reportFormat);
    dc.setCapability("testName", testName);
    dc.setCapability(MobileCapabilityType.UDID, "f5a19fd4");
    dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.pegipegi.android");
    dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, ".main.activities.SplashActivity");
    dc.setCapability("instrumentApp", true);
    driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), dc);
    driver.setLogLevel(Level.INFO);
}
 @Test
public void testtiket1adult() {
    driver.findElement(By.xpath("//*[@id='it_next' and (./preceding-sibling::* | ./following-sibling::*)[./*[@text='Tiket Pesawat']]]")).click();
    new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@text='CARI TIKET' and @width>0]")));
    driver.findElement(By.xpath("//*[@text='CARI TIKET' and @width>0]")).click();
    driver.findElement(By.xpath("//*[@text='per orang' and ./parent::*[./parent::*[(./preceding-sibling::* | ./following-sibling::*)]]]")).click();
    driver.findElement(By.xpath("//*[@text='Pesan']")).click();
}
 @After
public void tearDown() {
    driver.quit();
}

}

Barbora
  • 921
  • 1
  • 6
  • 11
bandit 1
  • 1
  • 1
  • 2
    Please provide the code as text and not as a picture. :) – npkllr Sep 21 '18 at 09:56
  • Congrats on your first StackOverflow post! In addition to the suggestion by @npkllrif please also provide some logging output showing what/why/how the tests fail :) – Maximilian C. Sep 21 '18 at 09:59
  • already update @MaximilianC. – bandit 1 Sep 21 '18 at 10:11
  • junit library is missing on classpath while executing the jenkins job... maybe this helps: https://stackoverflow.com/questions/12407560/how-to-setup-jenkins-with-junit – Tommy Brettschneider Sep 21 '18 at 11:44
  • got error : C:\Program Files (x86)\Jenkins\workspace\junit\build.xml:31: The or for must include junit.jar if not in Ant's own classpath @TommyBrettschneider – bandit 1 Sep 21 '18 at 15:51
  • for reference i need like this https://www.youtube.com/watch?v=OvbIWlOFEEQ i already follow like video. but still can't success build in jenkins – bandit 1 Sep 21 '18 at 15:53
  • @bandit1 try to use Maven build & mention the dependencies in pom.xml, since you are using build.xml you may need to upload the junit.jar with your project classpath or create folder under your project "lib" put your dependencies jar in that folder – Mani Sep 23 '18 at 04:19
  • @Manidroid yup i already copy all lib appium to my workspace in jenkins. test already run but with error bellow: java.lang.ClassNotFoundException: junit at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) – bandit 1 Sep 24 '18 at 08:47
  • Then your libs are not set in your classpath thats y its showing error, try with maven dependency it will download and set your classpath – Mani Sep 25 '18 at 00:27

0 Answers0