I am using Selenium and Java to write a test, I added the code below to see if I am using a wrong Chrome driver,
try {
System.setProperty("webdriver.chrome.driver", "Chrome Drivers\\chromedriverLinux32");
} catch (Exception e) {
System.out.println(1);
e.printStackTrace();
}
but whenever it happens, the test throws:
Jan 14, 2016 11:04:25 AM org.openqa.selenium.os.UnixProcess checkForErrorSEVERE: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "C:\Users\sina\Desktop\WorkSpace\CowZAllPages\Chrome Drivers\chromedriverLinux32" (in directory "."): CreateProcess error=193, %1 is not a valid Win32 application)
But the catch does catch any errors ( System.out.println(1);
is not seen).
There's nothing wrong with your code in the way you assign the Chrome Path. The System literally gets that string.
You'll want to have a look at the driver initialization and put a try-catch there, in order to catch such exceptions.
Update:
Perhaps you need to revise this use case - in the sense that you can have 3 ChromeDriver paths and use the right one depending on the platform.
System.getProperty("os.name")
This way, you'll always use the right ChromeDriver.
The last part of the error says "not a valid Win32 application". Is "Chrome Drivers\\chromedriverLinux32" an .exe? Do you need to add the file extension?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.