findElementByName is not working ?
See original GitHub issueI am trying to automate an application using Java. Following are my configuration details,
Appium
<dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>5.0.4</version> </dependency>Driver version: v1.0
Code:
DesiredCapabilities capability = new DesiredCapabilities(); capability.setCapability("app", "C:\\Users\\<current user>\\Desktop\\App.lnk"); capability.setPlatform(Platform.WIN10); try { driver = new WindowsDriver<WindowsElement>(new URL("http://127.0.0.1:4723"), capability); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); Thread.sleep(5000); } catch (MalformedURLException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } WindowsElement element = driver.findElementByName("Folder Compare"); element.click();
Exception:
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.6.0’, revision: ‘6fbf3ec767’, time: ‘2017-09-27T15:28:36.4Z’ System info: host: ‘PC252611’, ip: ‘10.219.211.41’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_121’ Driver info: io.appium.java_client.windows.WindowsDriver Capabilities [{app=C:\Users\589103\Desktop\Beyond Compare 4.lnk, javascriptEnabled=true, platformName=WINDOWS, platform=WINDOWS}] Session ID: 4B584146-AAB2-4875-A29A-A5C68A676C3B *** Element info: {Using=name, value=Folder Compare} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:82) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:45) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:89) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42) at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:356) at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:62) at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.findElement(WindowsDriver.java:1) at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:434) at io.appium.java_client.DefaultGenericMobileDriver.findElementByName(DefaultGenericMobileDriver.java:110) at io.appium.java_client.AppiumDriver.findElementByName(AppiumDriver.java:1) at io.appium.java_client.windows.WindowsDriver.findElementByName(WindowsDriver.java:1) at WinApp.main(WinApp.java:32)
Used inspect.exe to spy an object and tried to click the button named “Folder Component”
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
Hi @kumarkrish85,
Beyond Compare 4 application opens a temporary application window with
Tapplication
ClassName
on application startup. Windows Application Driver treats this temporary window as the main application window for the created session. This window will eventually disappears when the actual main application window containing the Folder Compare button appears. But at this point, your WinAppDriver session is still pointing to the temporary window and as a result you will not be able to locate the button.To overcome this scenario, you can simply switch the created session to the main application window as soon as it appears. For example:
Hi @Kranthi9704,
Can you please open a new issue with additional logs (from WinAppDriver.exe console)?
Closing this ticket as original issue seems to be resolved.