Winium.Desktop icon indicating copy to clipboard operation
Winium.Desktop copied to clipboard

Winium is clicking on wrong element

Open avian27 opened this issue 6 years ago • 28 comments

I am new to winium and wanted some help. I tried to run a simple calculator automation test of adding 1 and 5. The automation id is 131 for 1 but when I am running the code it's clicking on '+'. Also I had to insert a sleep of 5 secs before calling the next function. When I did not insert the sleep it will simply go to next step without performing any operation. The same code is working on a different machine. I am not able to figure out what is the problem.

avian27 avatar May 18 '18 08:05 avian27

The automation ID your trying to match is not correct. Inspect the Calculator UI with "UISpy" and check whether the ID your checking is present or not?

VSKSunny avatar May 23 '18 12:05 VSKSunny

The automation id which i am getting is the same when i used UISPY or Inspect.

Thanks, Avinash

On Wed, May 23, 2018, 18:04 VSKSunny [email protected] wrote:

The automation ID your trying to match is not correct. Inspect the Calculator UI with "UISpy" and check whether the ID your checking is present or not?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-391330108, or mute the thread https://github.com/notifications/unsubscribe-auth/AleuNQO4T0wJJ9YArk-9J-c79HpScPMsks5t1VdwgaJpZM4UEW8E .

avian27 avatar Jun 03 '18 08:06 avian27

Can u send a snapshot of ur code so that I can help in resolving..

VSKSunny avatar Jun 03 '18 08:06 VSKSunny

Here is the code that I am using

package acedemo;

import java.net.MalformedURLException; import java.net.URL;

import org.openqa.selenium.By; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver;

public class multiplerun {

public static void main(String[] args) throws MalformedURLException, InterruptedException { // TODO Auto-generated method stub DesktopOptions option1 = new DesktopOptions(); option1.setApplicationPath("C:\Windows\System32\calc.exe"); WiniumDriver driver1 = new WiniumDriver(new URL("http://localhost:9999 "),option1); Thread.sleep(7000); driver1.findElement(By.name("Calculator")).click(); driver1.findElement(By.id("138")).click(); Thread.sleep(10000); System.out.println("success");

}

}

The code starts the calculator exe but does not perform any clicking event and print success. The automation id used is for button 8. The code ideally should give an error when trying to click the specified element but instead, it moves on to next statement. The same code is running perfectly fine on another machine.

Also, we were involved in a POC for our automating our company product using winium. The product interacts with different executables and we were facing the issue while switching from 1 app to other if both the app launches over each other(i.e they overlap on each other). Sometimes it switches perfectly fine while some time it is unable to switch and then gives an error element not found. It will be awesome if u can suggest something regarding to this switching issue.

Thanks, Avinash.

On Sun, Jun 3, 2018 at 2:08 PM, VSKSunny [email protected] wrote:

Can u send a snapshot of ur code so that I can help in resolving..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-394146515, or mute the thread https://github.com/notifications/unsubscribe-auth/AleuNYngxVyUU6aN7stAkTfYreT4QcfOks5t46BtgaJpZM4UEW8E .

avian27 avatar Jun 05 '18 06:06 avian27

Display scale is 100%? If no, change to 100% restart PC and try again

heilwood avatar Jun 26 '18 11:06 heilwood

Hi all, I'm also facing this problem, driver takes most pointer a little further away from the element and then clicks. So it gives a NO CLICK exception.

Please help

hg13190 avatar Sep 11 '18 02:09 hg13190

Make the resolution of the screen of local machine as 100%, then try. Hope so it will work for you.

ranjan1522 avatar Sep 11 '18 09:09 ranjan1522

I did not understand what do you mean by making resolution to 100%. The resolution of my laptop is as per recommended settings and i am not resizing the calculator

On Tue 11 Sep, 2018, 15:25 prabhatranjan2206, [email protected] wrote:

Make the resolution of the screen of local machine as 100%, then try. Hope so it will work for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-420216599, or mute the thread https://github.com/notifications/unsubscribe-auth/AleuNahClrZX1qL-qjyJCP9vkI-sXFvNks5uZ4iDgaJpZM4UEW8E .

avian27 avatar Sep 13 '18 08:09 avian27

Hi, thanks @prabhatranjan2206 that fixed the issue

All I did was changed the display scale to 96 dpi i.e 100%

hg13190 avatar Sep 15 '18 17:09 hg13190

Thanks @heilwood

hg13190 avatar Sep 15 '18 17:09 hg13190

Hi,

Sorry could not reply to you earlier but after changing the display scale it solve my problem. Thanks for your help.

On Tue 11 Sep, 2018, 15:25 prabhatranjan2206, [email protected] wrote:

Make the resolution of the screen of local machine as 100%, then try. Hope so it will work for you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-420216599, or mute the thread https://github.com/notifications/unsubscribe-auth/AleuNahClrZX1qL-qjyJCP9vkI-sXFvNks5uZ4iDgaJpZM4UEW8E .

avian27 avatar Oct 13 '18 15:10 avian27

My entire script of desktop application was running successfully through winium. From past two days randomly it stopped. Please help me resolve this. Now winium driver is able to recognize the element name, but not clicking over there. Exception found, no such element.html found.

Suruchi-mindstix avatar Jul 23 '19 19:07 Suruchi-mindstix

Hi, i am using winium with java code ,it is clicking on some other element instead of clicking on located element. System having Display scale is 100% and windows 10(version 1803)

gdsushma avatar Jul 24 '19 14:07 gdsushma

Are you sure that no elements with same id exists somewhere else?

heilwood avatar Jul 25 '19 05:07 heilwood

actually ,This element don't have ID and it is having Name, i used Name to locate the element. this element is a button on the application.

gdsushma avatar Jul 25 '19 05:07 gdsushma

My entire script of desktop application was running successfully through winium. From past two days randomly it stopped. Please help me resolve this. Now winium driver is able to recognize the element name, but not clicking over there. Exception found, no such element.html found.

Issue has been resolved By updating jar.

Suruchi-mindstix avatar Jul 26 '19 09:07 Suruchi-mindstix

I am into this issue. I am using name to get the element to click as there is no automation id. Its clicking on a different element . My Application is maximised and not sure where I need to add the display 100% to try it. Could you help please?

My test example:

public void ViewSiteBACnetPointsUploaded()

{
        var controllerTab = GetElementByName(driver, "Controller", 10000);
        if (controllerTab != null)
        {

            controllerTab.Click();
        }
        else
        {
            Console.WriteLine("did not find");
        }

        Console.WriteLine("Controller tab is Opened ");

        var uploadBAC = GetElementByName(driver, "Upload BACnet Points", 50000);
        if (uploadBAC != null)
        {

        uploadBAC.Click();
        }
        else
        {
            Console.WriteLine("did not find");
       }

     Console.WriteLine("Upload BACnet Points option opened ");

    }

anileapen avatar Dec 03 '19 09:12 anileapen

I have two monitors. When I just run with my laptop screen, the script works. When I add the second monitor, even thought the script runs on the laptop monitor, it clicks on the wrong button.

any suggestions?

betsy-dugas avatar Sep 03 '20 13:09 betsy-dugas

Hi, I Am Akash, in my case Application is open but not performing elements in the right place click. my code is below.

package desktop222;

import java.net.MalformedURLException; import java.net.URL;

import org.openqa.selenium.By; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver;

public class mytestig { static DesktopOptions Test; public static void main(String[] args) throws MalformedURLException, InterruptedException { // TODO Auto-generated method stub DesktopOptions Test = new DesktopOptions(); Test.setApplicationPath("C:\Program Files\MySegmenter 2.0.0-2022-04-17\MySegmenter.exe"); WiniumDriver driver = new WiniumDriver(new URL("http://localhost:9999"),Test);

//WebElement window =driver.findElementByClassName("QToolBar");
//WebElement button =window.findElement(By.name("MYS_Sidebar").findElement(By.name("File")));
//button.click();

driver.findElementByName("File").click();
driver.findElement(By.name("Edit")).click();

} }

and Display resolution 100%. please Reply.

akashraval0311 avatar Apr 29 '22 05:04 akashraval0311

Check if the ide is giving u error on the below lines

driver.findElementByName("File").click(); driver.findElement(By.name("Edit")).click();

I believe there is syntax error there

On Fri, 29 Apr, 2022, 10:49 Akash Raval, @.***> wrote:

Hi, I Am Akash, in my case Application is open but not performing elements in the right place click. my code is below.

package desktop222;

import java.net.MalformedURLException; import java.net.URL;

import org.openqa.selenium.By; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver;

public class mytestig { static DesktopOptions Test; public static void main(String[] args) throws MalformedURLException, InterruptedException { // TODO Auto-generated method stub DesktopOptions Test = new DesktopOptions(); Test.setApplicationPath("C:\Program Files\MySegmenter 2.0.0-2022-04-17\MySegmenter.exe"); WiniumDriver driver = new WiniumDriver(new URL(" http://localhost:9999"),Test);

//WebElement window =driver.findElementByClassName("QToolBar"); //WebElement button =window.findElement(By.name("MYS_Sidebar").findElement(By.name("File"))); //button.click();

driver.findElementByName("File").click(); driver.findElement(By.name("Edit")).click();

} }

and Display resolution 100%. please Reply.

— Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112885735, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJL24NI7FMAXT3BBNVKQ623VHNWPDANCNFSM4FARN4CA . You are receiving this because you authored the thread.Message ID: @.***>

avian27 avatar Apr 29 '22 05:04 avian27

No Error in this line @avian27

akashraval0311 avatar Apr 29 '22 05:04 akashraval0311

Can u share the screenshot of the ide and the error message that u are getting there

On Fri, 29 Apr, 2022, 11:27 Akash Raval, @.***> wrote:

No Error in this line @avian27 https://github.com/avian27

— Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112902116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJL24NI4AI4PKXFNLROKZALVHN25PANCNFSM4FARN4CA . You are receiving this because you were mentioned.Message ID: <2gis/Winium .@.***>

avian27 avatar Apr 29 '22 06:04 avian27

I Am fetching Element by Name and there is no error message.The application is open is properly but not the .click() element. Screenshot (10)

@avian27

akashraval0311 avatar Apr 29 '22 06:04 akashraval0311

i wanted the screenshot of the ide after u ran the code

On Fri, 29 Apr, 2022, 12:03 Akash Raval, @.***> wrote:

I Am fetching Element by Name and there is no error message.The application is open is properly but not the .click() element. [image: Screenshot (10)] https://user-images.githubusercontent.com/96419112/165895251-07ec90cd-d429-4a9b-905d-4d75672d6161.png

— Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112919423, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJL24NJ4XI4YD6BYJUFIZALVHN7ELANCNFSM4FARN4CA . You are receiving this because you were mentioned.Message ID: <2gis/Winium .@.***>

avian27 avatar Apr 29 '22 06:04 avian27

console windows like this show messages.

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Element cannot be found (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 30.64 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'DESKTOP-KPMRHQC', ip: '192.168.0.103', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1' Driver info: org.openqa.selenium.winium.WiniumDriver Capabilities [{app=C:\Program Files\MySegmenter 2.0.0-2022-04-17\MySegmenter.exe, args=, innerPort=9998, debugConnectToRunningApp=false, keyboardSimulator=1, launchDelay=0, platform=ANY}] Session ID: AwesomeSession *** Element info: {Using=name, value=Settings} at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:451) at org.openqa.selenium.By$ByName.findElement(By.java:303) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:345) at desktop222.mytestig.main(mytestig.java:18) @avian27

akashraval0311 avatar Apr 29 '22 06:04 akashraval0311

Use updated driver

On Fri, Apr 29, 2022, 12:08 PM Avinash Chauhan @.***> wrote:

i wanted the screenshot of the ide after u ran the code

On Fri, 29 Apr, 2022, 12:03 Akash Raval, @.***> wrote:

I Am fetching Element by Name and there is no error message.The application is open is properly but not the .click() element. [image: Screenshot (10)] < https://user-images.githubusercontent.com/96419112/165895251-07ec90cd-d429-4a9b-905d-4d75672d6161.png

— Reply to this email directly, view it on GitHub < https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112919423 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AJL24NJ4XI4YD6BYJUFIZALVHN7ELANCNFSM4FARN4CA

. You are receiving this because you were mentioned.Message ID: <2gis/Winium .@.***>

— Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112921710, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMOKRXBLR35C2KIOF3R3323VHN7UTANCNFSM4FARN4CA . You are receiving this because you commented.Message ID: <2gis/Winium. @.***>

Suruchi-mindstix avatar Apr 29 '22 06:04 Suruchi-mindstix

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Element cannot be found (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.75 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'DESKTOP-KPMRHQC', ip: '192.168.0.103', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1' Driver info: org.openqa.selenium.winium.WiniumDriver Capabilities [{app=C:\Program Files\MySegmenter 2.0.0-2022-04-17\MySegmenter.exe, args=, innerPort=9998, debugConnectToRunningApp=false, keyboardSimulator=1, launchDelay=0, platform=ANY}] Session ID: AwesomeSession *** Element info: {Using=xpath, value=File} at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:490) at desktop222.mytestig.main(mytestig.java:18) after update driver same worning@avian27

akashraval0311 avatar Apr 29 '22 07:04 akashraval0311

I faced the same issue. I used the driver which was not merged by company. That was edited via users. And that worked for me. Hope this will use full for you. Thanks

On Fri, Apr 29, 2022, 12:36 PM Akash Raval @.***> wrote:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Element cannot be found (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.75 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06' System info: host: 'DESKTOP-KPMRHQC', ip: '192.168.0.103', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1' Driver info: org.openqa.selenium.winium.WiniumDriver Capabilities [{app=C:\Program Files\MySegmenter 2.0.0-2022-04-17\MySegmenter.exe, args=, innerPort=9998, debugConnectToRunningApp=false, keyboardSimulator=1, launchDelay=0, platform=ANY}] Session ID: AwesomeSession *** Element info: {Using=xpath, value=File} at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647) at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353) at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:490) at desktop222.mytestig.main(mytestig.java:18) after update driver same @.***

— Reply to this email directly, view it on GitHub https://github.com/2gis/Winium.Desktop/issues/233#issuecomment-1112938428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMOKRXDTJCLXXHD4WBZZ5I3VHODAHANCNFSM4FARN4CA . You are receiving this because you commented.Message ID: <2gis/Winium. @.***>

Suruchi-mindstix avatar May 01 '22 03:05 Suruchi-mindstix