Hi,
Yes issues definitely my java skills not Appium at the moment!
I have changed cap to caps as you mentioned. However I’m getting a problem that says:
My whole AppiumTest class code is below.
package tests;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
public class AppiumTest {
public static void main(String[] args) {
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.DEVICE_NAME, "ZY224Gs7NG");
caps.setCapability(MobileCapabilityType.APP_PACKAGE, "com.android2.calculator3");
caps.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.xlythe.calculator.material.Calculator");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "MobilePlatform.ANDROID");
//Instantiate Appium Driver
try {
AppiumDriver<MobileElement> driver = new AndroidDriver<>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
@Test
public void Test() {
try {
driver = new AndroidDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
// Click on number 7
WebElement sevenKey = driver.findElement(By.xpath("//android.widget.Button[contains(@resource-id,‘button7’)]"));
sevenKey.click();
// Click on '+'
WebElement plusKey = driver.findElement(By.xpath("//android.widget.Button[contains(@resource-id,‘buttonPlus’)]"));
plusKey.click();
// Click on number 5
WebElement fiveKey = driver.findElement(By.xpath("//android.widget.Button[contains(@resource-id,‘button5’)]"));
fiveKey.click();
// Click on '='
WebElement equalsKey = driver.findElement(By.xpath("//android.widget.Button[contains(@resource-id,‘buttonEquals’)]"));
equalsKey.click();
// Check the total is correct
WebElement total = driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,‘textField’)]"));
String totalValue = total.getText();
Assert.assertEquals(“12”, totalValue);
}}