jeudi 11 janvier 2018

Appium android buttons strange working

I have problem with testing my app which is intended for online shopping. I noticed that all buttons from aplication working but I have problem with system buttons(look at the picture). I’m using to recognize the button UiAutomatorViewer. At the picture I’m trying add product to cart but when I’m click button “Dodaj”(means Add) the window closes but there are any actions in application, the product should be added to cart. I tested this application manually and everythings work correct. I tried to operate the button in many ways but still nothing. Does anyone know how to solve it? It’s very important functions to testing for me.

enter image description here

public class Product extends MainPage {
private AndroidDriver<AndroidElement> driver;

@FindBy(id = "com.mec.leroy:id/product_add_to_cart")
private WebElement addToCart;

@FindBy(xpath = "//android.widget.Button[@index='1']") //problem with button
private WebElement buttonAdd;

@FindBy(id = "com.mec.leroy:id/product_name")
private WebElement productName;

public Product(AndroidDriver driver) {
    super(driver);
    this.driver = driver;
}


public Product addProduct() throws InterruptedException {
    driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"do koszyka\"));");
    addToCart.click();
    buttonAdd.click();
    Thread.sleep(5000);
    return new Product(driver);
}

public boolean productName() throws InterruptedException {
    Thread.sleep(2000);
    try {
        productName.getText();
        return true;
    } catch (ElementNotVisibleException e) {
        return false;
    }
}

public class Connector {
public AndroidDriver Settings() throws IOException, InterruptedException {

    runAppium();
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "33004db396a6c2d1"); // nazwa urządzenia
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");

    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
    capabilities.setCapability("noRest", "true");
    capabilities.setCapability("fullReset", "false");

    // capabilities.setCapability("useKeystore", "true");
    //uruchomienie aplikacji z poziomu telefonu
    capabilities.setCapability("appPackage", "com.mec.leroy");
    capabilities.setCapability("appActivity", "com.mec.leroy.main.activity.MainActivity");

    //inicjalizacja połączenia z Appium Server

    AndroidDriver<AndroidElement> driver = new AndroidDriver<AndroidElement>(new URL("http://ift.tt/1sv2im4"), capabilities);
    return driver;

}

Aucun commentaire:

Enregistrer un commentaire