Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winium: Using Winium in Windows 11, not correctly clicking on the button in Calculator application #356

Open
ramkumarsivanandan opened this issue Jul 12, 2022 · 0 comments

Comments

@ramkumarsivanandan
Copy link

ramkumarsivanandan commented Jul 12, 2022

Hi,

I'm using Windows 11 and trying to automate Calculator.exe, and below are dependency.

package testcases;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;

public class MyFirstTestCase {
	public static void main(String args[]) throws MalformedURLException, InterruptedException {
		
		DesktopOptions desktopOptions = new DesktopOptions();
		desktopOptions.setApplicationPath("C:\\Windows\\System32\\calc.exe");
		//desktopOptions.setLaunchDelay(3000);
		WiniumDriver winiumDriver = new WiniumDriver(new URL("http://localhost:9999"), desktopOptions);
		try {
			Thread.sleep(4000);
			Actions actions = new Actions(winiumDriver);
			
			
			WebElement oneButton = winiumDriver.findElement(
					By.xpath("/*[@Name='Calculator' and @LocalizedControlType='window']"
							+ "/*[@Name='Calculator' and @LocalizedControlType='window']"
							+ "//*[@LocalizedControlType='group' and @ClassName='LandmarkTarget']"	
							+ "/*[@Name='Number pad' and @ClassName='NamedContainerAutomationPeer']"
							+ "/*[@AutomationId='num1Button']"
							));
			
			WebElement twoButton = winiumDriver.findElement(
					By.xpath("/*[@Name='Calculator' and @LocalizedControlType='window']"
							+ "/*[@Name='Calculator' and @LocalizedControlType='window']"
							+ "//*[@LocalizedControlType='group' and @ClassName='LandmarkTarget']"	
							+ "/*[@Name='Number pad' and @ClassName='NamedContainerAutomationPeer']"
							+ "/*[@AutomationId='num2Button']"
							));
			
			//oneButton.click();
			actions.click(oneButton);
			actions.perform();
			Thread.sleep(2000);
			//twoButton.click();
			actions.click(twoButton);
			actions.perform();
			Thread.sleep(2000);
						
		} catch(Exception e) {
			e.printStackTrace();
		}	
	}
}

When I try to execute, Calculator.exe application gets popped up, but on my first click on numeric button "1", Calculator window get minimized and it dint click on the "1" button. Second click on numeric button "2" throws error.

org.openqa.selenium.WebDriverException: Unrecognized error. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4 milliseconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'LAPTOP-0LQSGR9A', ip: '172.31.98.220', os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1.1'
Driver info: org.openqa.selenium.winium.WiniumDriver
Capabilities [{app=C:\Windows\System32\calc.exe, args=, innerPort=9998, debugConnectToRunningApp=false, keyboardSimulator=1, launchDelay=0, platform=ANY}]
Session ID: AwesomeSession
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.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.mouseMove(RemoteMouse.java:89)
at org.openqa.selenium.interactions.internal.MouseAction.moveToLocation(MouseAction.java:59)
at org.openqa.selenium.interactions.ClickAction.perform(ClickAction.java:36)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:50)
at org.openqa.selenium.interactions.Actions.perform(Actions.java:373)
at testcases.MyFirstTestCase.main(MyFirstTestCase.java:47)

I see people reported this issue for Windows and was asked to change the scaling. In Settings > Display > Scale section, I changed it to 100%, 125%, 150% and 175%, but still click dint happen in the place.

Kindly let me know what setting to be tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant