Tuesday, 9 August 2022

How to give relative path to run AutoIT .exe file in Selenium Java for windows based authentication

Using System.getProperty, we can provide relative path of AutoIT and then use Runtime.getRuntime().exec("PathToAutoITExeFile") method to do the windows based authentication in selenium. 

For instance: 
System.getProperty("user.dir")+"\\src\\test\\resources\\files\\atuoit_chrome_credentials.exe")

Tip credits: Co-Engineer 


 
	@Given("Products URL with AutoIT credentials entered")
	public void givenChromeBrowser() throws Throwable {

		// Get the credentials from AutoIT script file
		
		// Absolute path
		//Runtime.getRuntime().exec("C:\\Automation\\atuoit_chrome_credentials.exe.exe");
		
		// Relative path 
		Runtime.getRuntime().exec(System.getProperty("user.dir")+"\\src\\test\\resources\\files\\atuoit_chrome_credentials.exe");
		
		// Get the login with windows based authentication 
		driver.get("http://www.products.com");
	}


No comments:

Post a Comment