I am running automation test with Selenium, Maven (my code is written in Java) on a remote machine.
On my virtual machine (Ip: 10.31.142.13) (the one I am running the browsers on): I have folder C:\Selenium with contains selinum server jar file, and IE driver and chrome driver. I run this command:
java -jar selenium-server-standalone-2.44.0.jar -mode hub
On my local machine (the one I run the tests from): I run the test with firefox on virtual machine, and it was successful. But my problem is with IE driver executable file: I don't know how to give the path to folder on my virtual machine. This is my code:
#Test //this test runs successfully
public void firefoxViewerTest() throws MalformedURLException
{
System.out.println("Firefox test starting ...");
DesiredCapabilities capability = DesiredCapabilities.firefox();
driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);
driver.manage().deleteAllCookies();
driverWait = new WebDriverWait(driver, 60);
baseActions();
System.out.println("Firefox test pass");
}
#Test
public void ieViewerTest() throws MalformedURLException
{
System.out.println("IE test starting ...");
//I want to use path to C:\Selenium on my virtual machine here
System.setProperty("webdriver.ie.driver", "\\Selenium\\IEDriverServer.exe");
DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
driver = new RemoteWebDriver(new URL("http://10.31.142.13:4444/wd/hub"), capability);
driver.manage().deleteAllCookies();
driverWait = new WebDriverWait(driver, 60);
baseActions();
System.out.println("IE test pass");
}
Any thoughts appreciated. Thanks
Thanks #PriyanshuShekhar for the suggestion. I run the command with -Dwebdriver in front, on the node, and I can run all web browsers IE; FF, Chrome without setting property.
java -Dwebdriver.ie.driver=C:\Selenium\IEDriverServer.exe -jar selenium-server-standalone-2.44.0.jar -mode hub
Related
I have been scratching my head with this issue, I can get chrome app running but firefox will not. I have added geckodriver.exe to my path variables (both user and system), install Firefox 64bit, and done all prerequisites to run appium tests (including reading this appium guide). I realise through searching the web this is a recent appium update, so I feel a bit like I'm in uncharted territory.
Below is the code I have along with the error message when attempting to run (TestNG)
public class test {
public AndroidDriver<MobileElement> driver;
public WebDriverWait wait;
#BeforeMethod
public void setup() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
System.setProperty("webdriver.gecko.driver", "C:\\Users\\Jack\\Downloads\\drivers\\geckodriver.exe");
caps.setCapability("deviceName", "sdk_gphone_x86");
caps.setCapability("udid", "emulator-5554"); //DeviceId from "adb devices" command
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "11.0");
caps.setCapability("automationName", "Gecko");
caps.setCapability("browserName", "firefox");
caps.setCapability("skipUnlock", "true");
caps.setCapability("noReset", "false");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), caps);
wait = new WebDriverWait(driver, 10);
}
#Test
public void basicTest() throws InterruptedException {
TimeUnit.SECONDS.sleep(5);
}
#AfterMethod
public void teardown() {
driver.quit();
}
}
Error
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: geckodriver.exe binary cannot be found in PATH. Please make sure it is present on your system
Server Log
Go to Environment variables->System variables->Path variable->Click on edit->Give the path of geckodriver.exe folder(do mention the folder name where geckodriver.exe resides) Ex:- C://Users//Downloads//GeckodriverFolder
Create another system variable "geckodriver" and provide the same path of geckodriver.exe stored folder.
Apply changes and restart IDE and execute the testcase.
I have application where I need to use Selenium with Firefox Webdriver.
I'm using below configurations:
OS : Windows 8
IDE : Eclipse
Selenium 3 and tomcat7.
Mozilla version : 54.0.1
Geckodriver version: 0.18.0
Here is the code snapshot of what I've done so far.
System.setProperty("webdriver.gecko.driver", "C:\\Users\\dalakada1\\Desktop\\dev\\geckodriver.exe");
System.out.println("1");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
System.out.println("2");
capabilities.setCapability("marionette", true);
System.out.println("3");
try
{
System.out.println("3.5");
//create driver
WebDriver driver = new FirefoxDriver();
System.out.println("4");
It doesn't go beyond 3.5.
I searched on Google and could not find anything useful.
Do I need to include geckodriver.exe in web-inf/res?
The ISSUE:
The geckodriver.exe is not loading when I run with testNG. Firefox will launch, but selenium cannot connect to the browser and I get an error:
Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. ....
My setup:
Windows 7
Eclipse Neon 3
Selenium 3.0.1
Geckodriver v0.13.0 (was using v0.11.1)
Firefox 48.0.2
First I created a quick test using Java and selenium. It just opens the browser and navigates to page. When this runs I see geckodriver process then the firefox process appear in the task manager.
Then I created a new project using Maven and testNG following the set-up from GURU99 web site. I have selenium and testNG added to the pom.xml file.
I used the convert project to testNG (xml file) and set the run configuration to run the XML file.
When I run the test I can see firefox process, then ff starts up. But the gecko driver process is never started.
Here is my code (excluding the imports):
public class NewTest {
private WebDriver driver;
#Test
public void test01() {
driver.get("http://www.startpage.com");
System.out.println("Pge title " + driver.getTitle());
}
#BeforeTest
public void beforeTest() {
System.setProperty("webdriver.gecko.driver", "c:\\selenium\\geckodriver.exe");
driver = new FirefoxDriver();
}
#AfterTest
public void afterTest() {
driver.quit();
}
}
You've missed to set the Marionette capability, e.g.
System.setProperty("webdriver.gecko.driver", <<Your driver path here>>);
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability(FirefoxDriver.MARIONETTE, true);
cap.setCapability(FirefoxDriver.BINARY, <<Your firefox.exe path here>>);
cap.setCapability(FirefoxDriver.PROFILE, <<Your firefox profile here>>);
driver = new FirefoxDriver(cap);
I am using the above and it works like charm!
For more, see: Selenium 3 using Firefox Geckodriver.
My code is not launching browser.
Project show running for a long time, but nothing happens. I pushed print and observed that WebDriver driver = new ChromeDriver(); is not getting executed.
package seleniumautomation;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
public class seleniumautomation {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:/selenium_java/chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("https://www.zaakpay.com/");
}
}
After some debugging, I am getting this new error:
I added manifest_vesion, but in every run, it is generating a new file and i am again getting same error.
Download jar from: http://chromedriver.storage.googleapis.com/index.html?path=2.23/
System.setProperty("webdriver.chrome.driver",
"<Downloaded file location>");
WebDriver driver = new ChromeDriver();
driver.get("https://www.zaakpay.com/");
Then, it will work.
To use Chrome Browser needs to System.setPropert("webdriver.chrome.driver","PATH")
The ChromeDriver is maintained / supported by the Chromium project iteslf. WebDriver works with Chrome through the chromedriver binary.
Download Link of ChromeDriver : LINK
You need to add chromedriver.exe(can be downloaded from http://www.seleniumhq.org/download/) to your project. Along with it, you need to add following lines in your code:
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
capabilities= DesiredCapabilities.chrome();
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
Use following code snippet to launch chrome driver.
System.setProperty("webdriver.chrome.driver", PATH_TO_EXE_FINAL);
ChromeOptions opt = new ChromeOptions();
opt.addArguments("disable-extensions");
opt.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(opt);
I solved the issue by changing my OS windows 10 language to english. selenium methods can not execute some other languages. If in both IE, geckodriver and chrome you are having the same issue it is language problem I can asuure you
enter image description hereTrying to check the version you installed in web driver and the version you currently use in you chrome
I have some tests using JUnit and Selenium, and I need to run it on the Chrome browser. I downloaded the Chrome driver, and configure my SetUp() as:
#Before
public void SetUp() throws Exception{
System.setProperty("webdriver.chrome.driver","");
driver = new ChromeDriver();
baseUrl = ;
driver.get(baseUrl);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);//Wait 5 seconds to load the page
}
The ChromeDriver.exe are added in my "Referenced Libraries" folder.
When I'll run the tests, the following error is displayed:
java.lang.exception: No runnable methods
Anybody know how can I fix this?
SOLUTION
1º Add the chromedriver in the path of your computer.
2º Update your setProperty as: System.setProperty("webdriver.chrome.driver","C:\\Users\\pedro_nazario\\Desktop\\ChromeDriver\\chromedriver.exe");
The second parameter must be the way where is your Chromedriver.exe in my case, the chromedriver are in a folder on desktop.
The most important thing, that you never forget
When you'll run the tests, before, close your Chrome browser completely. Any chrome browser must be open before you run your tests. If have some chrome browser opened, the selenium will take a error in your screen.
According to the documentation, webdriver.chrome.driver should contain the path to the chromedriver executable:
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
Alternatively, you can add path to the chromedriver to the PATH environment variable.