0

enter image description here

I'm automating my Windows application.

I'm using Winapp driver and Java language for automation. I am capturing the web elements using UI Spy Tool.

My application is loading, still I can't automate the login page. I'm getting the following error:

My Code:

public class Reporter 
{

    private static WindowsDriver<WindowsElement> driver;

    public static void main(String args[])  
                           throws MalformedURLException, InterruptedException 
    {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        String homePath = System.getenv("USERPROFILE");
        capabilities.setCapability("app",  homePath + "\\AppData\\Local\\Apps\\2.0\\HHCZT7OJ.D37\\61K3K288.OXH\\base..tion_6e5be371fe594b2d_0001.0000_aad96dff3b16369b\\");
        WindowsDriver Session = new WindowsDriver(new URL("http://127.0.0.1:4723"), capabilities);

        Assert.assertNotNull(Session);
        Session.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

        DesiredCapabilities Appcapabilities = new DesiredCapabilities();
        Appcapabilities.setCapability("app", "Root");
        WindowsDriver AppSession = new WindowsDriver(new URL("http://127.0.0.1:4723"), Appcapabilities);
        Thread.sleep(5000);

        WebDriverWait wait=new WebDriverWait(AppSession, 30);

        AppSession.findElementByAccessibilityId("txtUserName").sendKeys("r_nave");
        AppSession.findElementByAccessibilityId("txtPassword").sendKeys("naveen");
        AppSession.findElementByAccessibilityId("btnLogin").click();
    }

}

Error::

Jul 16, 2018 10:19:47 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Jul 16, 2018 10:19:47 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Exception in thread "main" org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:42:44.417Z' System info: host: 'ANTONYW10', ip: '10.246.0.91', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '10.0.1' Driver info: io.appium.java_client.windows.WindowsDriver Capabilities [{app=Root, javascriptEnabled=true, platformName=XP, platform=XP}] Session ID: BB465F8F-3CE3-453C-99CB-BB517378A6B2 *** Element info: {Using=accessibility id, value=txtUserName}

Now it's working for me that I put thread.sleep 20000

1
  • Can you paste uiSpy screenshot showing where did you take the data for your locator? Also why is there an empty value in findElementByAccessibilityId in your example?
    – Alexey R.
    Commented Jul 11, 2018 at 13:15

1 Answer 1

0
  1. Can you provide the whole app schema? Where is this edit control nested in?
  2. Have you tried first doing:

    driver.findElementByAccessibilityId("txtUserName").click(); driver.findElementByAccessibilityId("txtUserName").sendKeys("");

3
  • Yes I tried this code, but its not working. getting same error
    – user24314
    Commented Jul 12, 2018 at 5:53
  • So where is nested this ControlType.Edit? Is it in some DataGrid? Basically you need first to set focus on parent control, and then you can type the keys Commented Jul 12, 2018 at 5:57
  • I am unable to solve my issue, can you please help me. I have been trying to solve this since 2 day
    – user24314
    Commented Jul 12, 2018 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.