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
Source: Read More