Hello Tom,
I forgot to say to you that i’m only testing Appium and Appium Studio without “code written” + usb device.
So the help you give me, with this code, it makes more sense if it is modified. If i have some program to execute like Eclipse.
"driver.executeScript(“client:client.setTestStatus(true,‘msg : test pass’)”); driver.executeScript(“client:client.setTestStatus(false,‘msg : test fail’)”);
e.g
String attribute1 = driver.findElement(By.xpath("//[@text=(‘Etape 9 : Conection Failure’)]")).getAttribute(“id”);
if (attribute1 == “failed”)
driver.executeScript(“client:client.setTestStatus(false,‘msg : test fail’)”);
else
driver.executeScript(“client:client.setTestStatus(true,‘msg : test pass’)”);"
But i’m started to testing with Eclipse Java + Appium Studio.
Searching contents about (how to working Eclipse with Appium Studio), the only way that i found, it was with plugin, but with cloud devices.
With my USB device i can’t have the url feedback report with passed or fail steps.
How can i be able to do it?
My code look like this
package org.test;
import static org.junit.Assert.assertEquals;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
//import junit.framework.TestCase;
//import org.junit.Test;
import org.junit.After;
import org.junit.Before;
//import org.junit.Test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Test {
static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException {
//Before
setUp();
sampleTest();
tearDown();
driver.executeScript(“client:client.setTestStatus(true,‘msg : test passed’)”);
driver.executeScript(“client:client.setTestStatus(false,‘msg : test fail’)”);
}
//Test
public static void sampleTest() {
MobileElement el1 = (MobileElement) driver.findElementById("…:id/username");
el1.sendKeys(“11”);
MobileElement el2 = (MobileElement) driver.findElementById("…:id/password");
el2.sendKeys(“11”);
MobileElement el3 = (MobileElement) driver.findElementById("…:id/loginButton");
el3.click();
MobileElement el4 = (MobileElement) driver.findElementById("…/loginStateMessage");
String attribute1 = driver.findElement(By.xpath("//[@text=('mauvais login/mot de passe')]")).getAttribute("id");
if (attribute1 == "failed")
driver.executeScript("client:client.setTestStatus(false,'msg : test fail')");
else
driver.executeScript("client:client.setTestStatus(true,'msg : test passed')");
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
public static void tearDown() {
driver.quit();
}
//After
public static void setUp() throws MalformedURLException {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("deviceName", "...");
desiredCapabilities.setCapability("platformName", "Android");
desiredCapabilities.setCapability("appPackage", "...l");
desiredCapabilities.setCapability("appActivity", "...");
desiredCapabilities.setCapability("udid", "...");
desiredCapabilities.setCapability("platformVersion", "5.0");
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), desiredCapabilities);
}
}