0

I am trying to do a POC for a windows app using winappdriver . I have the winappdriver version 1.1 installed up and running. I want to find the elements by using their automationId. As per winappdriver documentation, elements with AutiomationID can be located by "findElementByAccessibilityId". I am not able to see this locator strategy in my Eclipse intellisense. Instead "findElementsByAccessibilityId" ( notice elements) is been shown up. What should i do so that i can see "findElementByAccessibilityId" locator in intellisense.

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.appium.java_client.windows.WindowsDriver;

public class LoginTest {

    private static WindowsDriver<WebElement> driver = null;

    @BeforeClass
    public static void setup() throws MalformedURLException {

        DesiredCapabilities capabilities = new  DesiredCapabilities();
        capabilities.setCapability("app", "XXXXXXXXXXXXXXXXXXXXXX");
        capabilities.setCapability("platformName", "windows");
        capabilities.setCapability("deviceName", "windowsPC");
        capabilities.setCapability("appWorkingDir", "XXXXXXXXXXXXXXXXXXXXXXXXXX");
        driver = new WindowsDriver<WebElement>(new URL("http://127.0.0.1:4723"), capabilities);
        driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);     

    }

    @Test
    public void Testing()
    {
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.findElement(By.className("TextBox")).sendKeys("XXXX");

        driver.findElementById("TxtPwd").sendKeys("XXXX");

        driver.findElementsByAccessibilityId("TxtPwd");

        driver.findElement(By.id("BtnLogin")).click();

        System.out.println("Hi");

    }

}

POM.xml

Prabhat
  • 33
  • 9
  • My best guess is that the variant without "s" isn't implemented in winappdriver for java. In .NET you get both. `findElementsByAccessibilityId` will give you a list with all elements that satisfy the condition (AccessibilityId). The element at index 0 will be the element you need in case of `findElementsByAccessibilityId`. – PixelPlex Jun 12 '19 at 11:49
  • @PixelPlex Thanks for your reply. I can see that the "findElementByAccessibilityId" is used in java samples provided in github from the winappdriver team. Could you please help me with lines of code by which I can click on the element which is at index 0. – Prabhat Jun 12 '19 at 15:02

0 Answers0