I am trying to write a selenium test with fluintlenium and for some reason when I try using the chrome driver it just open chrome on "data;" page and doesn't continue to the actual url I give it.
When I use HtmlUnitDriver it runs the test successfully but with chrome it just stuck after :
Starting ChromeDriver 2.15.322448 (****) on port 36888
Only local connections are allowed.
I know its just an information message but it doesnt continue after that just stuck it doesn't show any errors...
The code is:
public class IntegrationTest extends FluentTest {
public WebDriver driver;
#Override
public WebDriver getDefaultDriver() {
driver = new ChromeDriver();
return driver;
}
/**
* add your integration test here
*/
#Test
public void title_of_bing_should_contain_search_query_name() {
goTo("http://www.bing.com");
fill("#sb_form_q").with("FluentLenium");
submit("#sb_form_go");
assertThat(title()).contains("FluentLenium");
}
}
I tried using selenium's driver.get("url"); but its not working either .
EDIT : How I run the tests? 1. I just start my selenium server 2. I use play so I run the command play test OR 2. I use eclipse junit test runner to run a single test.
Both doesn't work ...
It doesn't mean the chromedriver is not launched. It's just an information message that you can connect to it only locally.
If the browser opened and not doing anything further, in your case it means you have not compatible chrome and chrome driver. If your chrome is the latest one, then 2.13 chromedriver is too old for you, try 2.15
Related
We are using Junit5 + Selenium/Webdriver to run parallel tests.
junit-platform.properties has this settings:
junit.jupiter.execution.parallel.enabled = true
junit.jupiter.execution.parallel.mode.default = concurrent
junit.jupiter.execution.parallel.mode.classes.default = concurrent
junit.jupiter.execution.parallel.config.dynamic.factor = 1.5
junit.jupiter.execution.parallel.config.strategy = dynamic
The Test*.java:
public class TestSuiteParallel extends TestSuite {
#RepeatedTest(2)
void testParallel() {
WebDriver driver = new ChromeDriver();
driver.get("https://www.amazon.com")
driver.quit();
}
}
Running in Linux everything works perfect, we have multiple Chromium windows handled separately by each thread worker. Headless or not, it works.
Running in Windows, always only ONE Chrome window with multiple tabs is openend. And only the last openend tab (in foreground) works sometimes. Mostly all tabs are frozen, nothing happens, after some seconds we get WebDriverException: unknown error: Chrome failed to start: crashed
If I change the code to #RepeatedTest(1) it runs without errors as expected.
So why this works so differently? Is there a setting I can force WebDriver to always open separate Browser windows? Or maybe it's more an operation system setting?
There is an existing question for the same problem but that question was not completely answered, so posting new question.
I am new to selenium and trying to execute the very basic script, but getting the compilation errors. I am using Eclipse Oxygen 4.7.2 and Selenium 3.8.1. I have added all the necessary Jar files and used the Geckodriver as well, still i am getting errors. Below are the error messages in the console window:
**"Exception in thread "main" java.lang.Error: Unresolved compilation problems:
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FirstTestCase {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("Webdriver.gecko.driver","C:\\Users\\vermap6\\Downloads\\geckodriver-v0.19.0-win64\\geckodriver.exe");
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
//Launch the Online Store Website
driver.get("http://www.google.com");
// Print a Log In message to the screen
System.out.println("Successfully opened the website www.google.com");
//Wait for 5 Sec
Thread.sleep(5000);
// Close the driver
driver.quit();
}
}
WebDriver cannot be resolved to a type
FirefoxDriver cannot be resolved to a type"**
Can anybody tell me what mistake i am doing ? Attaching screenshots. Webdriver Error.png JAr Files in Selenium 3.8.1
The problem is about file permission. I guess you are using Mac or Linux and the default permission of the library doesn't allow Eclipse to read it. What you need is going to the directory in Terminal and then use sudo chmod to change the permission.
sudo chmod -R 755 ./
Then you may need to restart Eclipse.
I am trying to create a simple automation task. For now I want to log in to the webpage. This all works fine when I run the test in Visual Studio 2017. However this will need to be executed as an exe on regular interval in windows system. When I run the executable it hangs after displaying:
Starting ChromeDriver 2.32.498550 (9dec58e66c31bcc53a9ce3c7226f0c1c5810906a)
on port 9515
Only local connections are allowed.
I understand this is just info not an error per most SO posts related to this issue such as - When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly
(note: my browser does not launch)
How do I run the test code as an executable?
Do I have to write additional code to invoke the test when running as executable?
Nuget Version Info
namespace RevuSeleniumAutomation
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.PhantomJS;
using System;
[TestClass]
public class RevuAutomater
{
private string baseURL = "http://example.com/";
private RemoteWebDriver driver;
private string browser;
public TestContext TestContext { get; set; }
[TestMethod]
[TestCategory("Selenium")]
[Priority(1)]
[Owner("Chrome")]
public void AutomateSite()
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30));
driver.Navigate().GoToUrl(this.baseURL);
driver.FindElementById("UserName").SendKeys("user");
driver.FindElementById("Password").SendKeys("12345");
}
[TestCleanup()]
public void MyTestCleanup()
{
driver.Quit();
}
[TestInitialize()]
public void MyTestInitialize()
{
}
}
}
The cmd window message after launching exe
Thank you for your time.
To run as EXE I think there are two options:
1) not with selenium server or grid
. you need package the chromedriver.exe with your code into the EXE
. you code need to calculate the path of chromedriver.exe in runtime, because you don't know user will put the EXE in which folder
. specify chromedriver.exe by ChromeOptions to tell selenium where to find it when create driver instance
Shortage of this way: a chromedriver.exe of certian version support limited chrome verions, not all chrome verions, you need to tell user which chrome the EXE support.
2) use selenium server/grid
. you code need accept selenium server/grid address from a config file which user can modify it
. create RemoteWebDriver instance with above address, not ChromeDriver in code
. no need to package chromedriver.exe with your code
Shortage of this way: A selenium server/grid need be ready before execute EXE,
But your code no need to consider the compatibility of chrome and chromedriver.exe, because they had been considered when setup selenium server/grid.
I was getting the error:
The path to driver executable must be set by the webdriver.gecko.driver system property
Then i downloaded geckodriver and set the path as below. After that the code is working fine.
But my question is do i need to use the below code every time (in each and every program) when i want to launch a firefox using selenium code?
System.setProperty("webdriver.gecko.driver","<path to geckodriver.exe>");
WebDriver driver = new FirefoxDriver();
When we work with Selenium 3.x, geckodriver and Mozilla Firefox Browser through Selenium-Java bindings we need to configure the Test Environment through System.setProperty line. Find the details along with your Answer below.
Your Question have 2 parts so I will answer both of them in parts:
1. Do I need to use the below code every time in each and every Program:
System.setProperty("webdriver.gecko.driver","<path to geckodriver.exe>");
WebDriver driver = new FirefoxDriver();
Answer:
Yes
Explaination:
Whenever we need to execute a program (Selenium-Java based) it is mandatory we explicitly mention the type of driver (gecko, chrome, ie) which we are trying to use in our program in the form of "webdriver.gecko.driver". Along with it, we also need to explicitly mention the absolute path of the driver (gecko, chrome, ie) binary (.exe) in the form of "<path to geckodriver.exe>". Next we are using the WebDriver interface and casting the WebDriver instance to FirefoxDriver.
2. Do I need to use the below code every time when i want to launch Firefox:
System.setProperty("webdriver.gecko.driver","<path to geckodriver.exe>");
Answer:
No
Explaination:
Once we configure the WebDriver instance i.e. the driver through DesiredCapabilities class, the driver is able to carry the same configuration till its life time which is controled through your Automation Script. So until and unless we explicitly call quit() method through the driver, the driver instance remains active and carries the configuration. So, within your program no matter how many time you choose to close the browser instance by calling close() method, you can always mention driver = new FirefoxDriver(); to open a new browser session again and again with the stored configuration within the driver.
An Example:
package demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class Driver_Close_Initiate
{
static WebDriver driver;
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability("marionette", true);
driver = new FirefoxDriver(dc);
driver.get("https://google.com");
driver.close();
driver = new FirefoxDriver(dc);
driver.get("https://facebook.com");
driver.quit();
}
}
The reason you need to use the gecko driver is your Firefox version is greater than v47. So to answer your question, if you don't want to use the gecko driver everytime, you need to downgrade your Firefox version to 47 or below.
Previous versions can be found here:
https://ftp.mozilla.org/pub/firefox/releases/
Yes you have to use setProperty(String key, String path) every time if you want to use Firefox version above 47 and selenium jars above 3.0.
System.setProperty("webdriver.gecko.driver", "Path of geckodriver.exe");
or, you can set the configurtion path using DesiredCapabilities classs
DesiredCapabilities des_capablity = DesiredCapabilities.firefox();
des_capablity.setCapability("marionette", true);
driver = new FirefoxDriver(des_capablity);
I get an error:
The file Capabilities [BrowserName=, IsJavaScriptEnabled=False, Platform=Any, Version=]\IEDriverServer.exe does not exist. The driver can be downloaded at http://code.google.com/p/selenium/downloads/list`
What must I do to solve this error because really I can't find information ....
Unless you're building the Selenium project from sources, or are using the .NET bindings and have set a specific option in the InternetExplorerOptions class, you shouldn't be seeing this message. The current source code is volatile in this particular area, as the project is currently implementing the usage of a standalone executable server for the IE driver, similar to what happens currently for the Chrome driver. If you are building from source, or are interested in using this new functionality, you should download the standalone IE driver server executable from the URL specified in the exception's message.
Download the IEDriver.exe for the given URL
http://code.google.com/p/selenium/downloads/list
Assuming the exe file is saved in E:\IEdriver.exe.
In Selenium you have to set the property of IEDriver, since Selenium has only firefox driver with it.
Set the system property and then invoke the IEDriver.
WebDriver driver;
System.setProperty("webdriver.ie.driver", "E:\\IEdriver.exe");
//Selenium will not support single slash, so we are providing double slash in path.
driver = new InternetExplorerDriver();
// By this it will call the IEDriver and execute
Thanks
An example to share:
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "D:\\selenium\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("www.google.com");
driver.findElement(By.id("gbqfq")).sendKeys("abc");
driver.close();
}
}