I have imported my selenium code from windows to mac and installed chromedriver for mac and updated systemproperty accordingly.but it is throwing exception and showing previously set path:
java.lang.IllegalStateException: The driver executable does not exist: /Users/Preet12/Desktop/Selenium/AddaStore/C:\Users\cp\Downloads\chromedriver_win32\chromedriver.exe
however the path in mac is : /Users/Preet12/Desktop/Selenium/AddaStore/chromedriver 2
it is showing path of window also i.e. C:\Users\cp\Downloads\chromedriver_win32\chromedriver.exe
Code:
public class WithTestNG
{
WebDriver driver;
#BeforeClass
public void StartBrowser()
{
System.setProperty("webdriver.chrome.driver","/Users/Preet12/Desktop/Selenium/AddaStore/chromedriver 2" );
driver = new ChromeDriver();
driver.manage().window().maximize();
}
Try Navigating to the folder containing chromedriver and run
"chmod +x chromedriver"
Related
Safari Version: 11.0.2
MAC Version: 10.12.6 Mac OS Sierra
selenium-java Version: 3.5.3
Language: JAVA
Whenever I am running a selenium test on Safari Driver it hangs after running few steps (could not find specific pattern). Same test run file on IOS/Safari, Android/Chrome, MAC/Chrome.
Works fine you run test in debug/step by step. What could be the reason Safari not responding?
Here is code to simulate the issue. Safari hangs and could not click 'Continue Shopping'
public static void main(String[] args) {
SafariOptions safariOptions = new SafariOptions();
safariOptions.setUseCleanSession(true);
// safariOptions.setUseTechnologyPreview(true);
DesiredCapabilities safariCapabilities = DesiredCapabilities.safari();
safariCapabilities.setJavascriptEnabled(true);
safariCapabilities.setAcceptInsecureCerts(true);
safariCapabilities.setPlatform(Platform.MAC);
safariCapabilities.setCapability("platformName", Platform.MAC);
safariCapabilities.setVersion("11.2");
safariCapabilities.setBrowserName("safari");
safariCapabilities.setCapability(SafariOptions.CAPABILITY, safariOptions);
WebDriver safariDriver = new SafariDriver(safariCapabilities);
safariDriver.manage().window().maximize();
safariDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
safariDriver.get("https://www.shoppersstop.com/");
waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[#href='cart']")));
safariDriver.findElement(By.xpath("//a[#href='cart']")).click();
waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[text()='Continue Shopping']")));
safariDriver.findElement(By.xpath("//a[text()='Continue Shopping']")).click();
}
public static <T> T waitFor(WebDriver safariDriver, ExpectedCondition<T> condition) {
return new FluentWait<WebDriver>(safariDriver).withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(500, TimeUnit.MILLISECONDS).until(condition);
}
Even the subj is dead I had the similar issue and the solution was to set
"Turn off display after" setting to "Never"
in
"Apple" > "Preferences" > "Energy Saver"
When I am trying to run the AutoIT.exe script or my Selenium script, it is throwing 'File Not found error'. Please suggest!
Selenium code snippet: ===================================
public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Users\\IBM_ADMIN\\Desktop\\Drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://demo.automationtesting.in/Register.html");
driver.manage().window().maximize(); Thread.sleep(2000);
driver.findElement(By.xpath("//input[#id='imagesrc' and #type='file']")).click();
Runtime.getRuntime().exec("C:\\Users\\IBM_ADMIN\\Desktop\\Selenium practise\\SeleniumAssignment\\AutoIT\\MultipleFileUpload.exe"+" "+"C:\\Users\\IBM_ADMIN\\Desktop\\0234_005.pdf"); Thread.sleep(2000);
driver.findElement(By.xpath("//input[#id='imagesrc' and #type='file']")).click();
Runtime.getRuntime().exec("C:\\Users\\IBM_ADMIN\\Desktop\\Selenium practise\\SeleniumAssignment\\AutoIT\\MultipleFileUpload.exe"+" "+"C:\\Users\\IBM_ADMIN\\Desktop\\BRP_SujataChakraborty.pdf"); driver.quit(); }
AutoIt Code Snippet: ============================
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1",$CmdLine[0])
ControlSetText("Open","","Edit1",$CmdLine[1])
ControlSetText("Open","","Edit1",$CmdLine[2])
ControlClick("Open","","Button1")
Is brower file dialog active window? If not auto it script will enter value in window whichever is active. Do make sure file dialog active?. Do interact with brower once it is started. And one more thing if you input type is file then you can use send keys instead of auto it to enter value.
I am a begineer in selenium and trying my own after installation of eclipse, java, selenium, TestNg and started writing the below code.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
WebDriver cannot be resolved to a type
FirefoxDriver cannot be resolved to a type
at Mypackage.MyClass.main(MyClass.java:8)
package Mypackage;
public class MyClass {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
String baseUrl = "http://google.com";
String expectedTitle = "Welcome: Hello";
String actualTitle = "";
driver.get(baseUrl);
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)) {
System.out.println("Test Passed!");
} else {
System.out.println("Test Failed");
}
driver.close();
}
}
you need to add selenium webdriver jar files to the project
right click on project-->goto build path-->configure build path-->click on "Add external jars"-->add selenium jar files from your local machine-->click ok-->now mouseover on WebDriver in your code-->click "import webdriver"--now run your code-->you will get rid of the exception.
I was trying to launch safari browser on real device(iPhone 4) using appium. but it is giving following error.
Unable to install [/var/folders/7_/fz8kyhyn2g97s1m9zylk50xc0000gq/T/11545-10782-1dp1wfm/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app] to device with id [fdaxxx76].
Error [Error: Command failed: /bin/sh -c /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id fda51be7184f865f02de4f4c6cb8fff760964e76 --bundle "/var/folders/7_/fz8kyhyn2g97s1m9zylk50xc0000gq/T/11545-10782-1dp1wfm/submodules/SafariLauncher/build/Release-iphoneos/SafariLauncher.app"
Below is my sample code:
DesiredCapabilities cap = new DesiredCapabilities();
private static WebDriver driver;
#BeforeTest
public void prep() throws MalformedURLException {
System.out.println("Script started");
cap.setCapability("platformName", "iOS");
cap.setCapability("platformVersion", "8.3");
cap.setCapability("deviceName", "iPhone4");
cap.setCapability("udid", "fda51be7184f865f02de4f4c6cb8fff760964e76");
cap.setCapability("browserName", "Safari");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
}
#Test
public void googleTest() {
System.out.println("main method");
driver.get("http://google.com");
}
You need to create a provisioning profile to deploy it to a real device.
Follow instructions here.
Hope this helps,
Liam
I am running selenium test cases in a ubuntu server which basically runs testcases in both firefox and chrome.
Firefox launches and test cases run successfully but chrome throws exception:
*****below is the snippet of the stacktrace:*****
Starting ChromeDriver (v2.8.240825) on port 21549
PAC support disabled because there is no system implementation
Test IntegrationTest.AdminUserelementscheck failed:
org.openqa.selenium.WebDriverException: chrome not reachable
(Driver info: chromedriver=2.8.240825,platform=Linux 2.6.32-431.el6.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
[error] Command duration or timeout: 20.83 seconds
Hi Below is the small snippet of my code :
public class IntegrationTest {
private static final String configFile="test.properties";
private final String FIREFOX="firefox";
private final String CHROME="chrome";
private final String PHANTOMJS="phantomjs";
private final String BROWSERNAME="browser";
private static Properties props = new Properties();
public WebDriver webDriver;
private static Configuration additionalConfigurations;
#BeforeClass
public static void setUp() throws IOException, SQLException{
props.load(IntegrationTest.class.getResourceAsStream("/" + configFile));
}
#test
public void AdminUserelementscheck() throws SQLException, IOException {
String[] browsers = props.getProperty(BROWSERNAME).split(",");
System.out.println("Number of browsers specified in conf:"+props.getProperty(BROWSERNAME));
for(String browser:browsers){
System.out.println("Browser currently processing:"+browser);
if(browser.equalsIgnoreCase(FIREFOX))
webDriver = new FirefoxDriver();
else if(browser.equalsIgnoreCase(CHROME))
webDriver = new ChromeDriver();
else
webDriver = new PhantomJSDriver();
running(testServer(3333,fakeApplication()),webDriver, new Callback<TestBrowser>() {
********* LOGIN AND ASSERTION STATMENTS*******************
browser.quit()
}
});
}
This would be because Chrome is also making use of unix containers in order to run. If you want this to run within docker, pass the docker run command
--privileged
Otherwise you can start Chrome with
--no-sandbox
I have encoutered similar problem. I am running my Selenium tests locally and "webdriver exception chrome not reachable" error suddenly showed up.
The problem was that I already had too much tabs in my regular chrome browser. After getting frustrated I have closed few tabs and suddenly it worked. I am not sure if there is a certain limit of tabs, but if somebody encounters same problem, give it a try.
Your chrome driver seems to be old. Try downloading latest as of date from below and report back if you get any new errors.
http://chromedriver.storage.googleapis.com/index.html?path=2.14/
Also ensure that PATH environment variable has the path to chromedriver.