Selenium chromedriver unknown error while running chrome 59 headless with browsermob proxy - selenium-chromedriver

I wrote a simple Selenium test (opening a page) of a secured site in a headless mode using Chrome 59 beta version.
I'm getting an the following exception while executing my code. The exception is thrown while initializing the driver
When I rerun my script after commenting the headless option (options.addArguments("headless")) it shows Chrome and running fine but my objective is to run it as headless. Could you please provide your thoughts on resolving my problem?
Exception:
Starting ChromeDriver 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b) on port 4971
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.14 seconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
Here are the steps:
I'm using Scala with SBT on Mac.
Chrome 59 beta version
ChromeDrive 2.29 release version.
Added the following dependencies
"org.seleniumhq.selenium" % "selenium-chrome-driver" % "3.4.0"
"org.seleniumhq.selenium" % "selenium-support" % "3.4.0"
"net.lightbody.bmp" % "browsermob-core" % "2.1.4"
Scala Code:
val username = "username"
val password = "password"
val domainname = "yoursecuredomain.com"
val browserMobProxyServer = new BrowserMobProxyServer()
browserMobProxyServer.start(0)
browserMobProxyServer.autoAuthorization(domainname, username, password, AuthType.BASIC)
val seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxyServer)
val options = new ChromeOptions()
options.addArguments("headless")
options.addArguments("--disable-gpu")
options.setBinary("""/Applications/Google Chrome.app/Contents/MacOS/Google Chrome""")
val desiredCapabilities = new DesiredCapabilities()
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options)
desiredCapabilities.setCapability(CapabilityType.PROXY, seleniumProxy)
val driver: WebDriver = new ChromeDriver(desiredCapabilities)
val baseUrlString = s"""https://$domainname"""
driver.navigate().to(baseUrlString)
Thread.sleep(3000)
println("title: " + driver.getTitle)
driver.quit()
browserMobProxyServer.abort()

According to the 2.29 webdriver notes page, It says that
----------ChromeDriver v2.29 (2017-04-04)----------
Supports Chrome v56-58
so u have to downgrade your chrome version to be compatible with the latest chrome webdriver.
source:
https://chromedriver.storage.googleapis.com/2.29/notes.txt

Related

Selenuim, WebDriver: SessionNotCreatedException: "errorMessage": "Message: session not created: Missing or invalid capabilities"

So I am using chrome driver version 103.0.5060.53 and chrome version 103.0.5060.114 running on an ECR image based on public.ecr.aws/lambda/python:3.9-x86_64. The error that I am getting with the first code is "errorMessage": "Message: session not created: Missing or invalid capabilities\n (Driver info: chromedriver=103.0.5060.53 (a1711811edd74ff1cf2150f36ffa3b0dae40b17f-refs/branch-heads/5060#{#853}),platform=Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)\n", "errorType": "SessionNotCreatedException"
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
if 'DOCKER_AUTH_CONFIG' in os.environ:
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
self.headless = True
chrome_opts.add_argument("window-size=1920,1080")
chrome_opts.binary_location = '/usr/bin/google-chrome'
chrome_opts.add_experimental_option('w3c', False)
desired_cap = {}
desired_cap['platform'] = 'ANY'
desired_cap['browserName'] = 'chrome'
desired_cap['loggingPrefs'] = {'performance': 'INFO'}
desired_cap['options'] = chrome_opts.to_capabilities()
self.driver = webdriver.Chrome(service = Service('/usr/local/bin/chromedriver'), options = chrome_opts, desired_capabilities=desired_cap)
And with the second code I am getting: "errorMessage": "Message: unknown error: Chrome failed to start: exited abnormally.\n (unknown error: DevToolsActivePort file doesn't exist)\n (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
if 'DOCKER_AUTH_CONFIG' in os.environ:
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
self.headless = True
chrome_opts.add_argument("window-size=1920,1080")
chrome_opts.binary_location = '/usr/bin/google-chrome'
chrome_opts.add_experimental_option('w3c', False) # Needed for chromedriver 75 (logging doesn't work in w3c mode)
desired_cap = {}
desired_cap['platform'] = 'ANY'
desired_cap['browserName'] = 'chrome'
desired_cap['loggingPrefs'] = {'performance': 'INFO'}
desired_cap['options'] = chrome_opts.to_capabilities()
self.driver = webdriver.Chrome(service = Service('/usr/local/bin/chromedriver'), desired_capabilities=desired_cap)
I don't know honestly what error is better than the other, I tried to play with many options according to what I found in the web.
Can somebody help me solve this issue and understand it please.
---- Update:
Now I am getting this error after using:
WebDriverException: Message: unknown error: unable to discover open window in chrome
(Session info: headless chrome=103.0.5060.114)
chrome_opts = Options()
chrome_opts.add_argument("--allow-running-insecure-content")
chrome_opts.add_argument('--headless')
chrome_opts.add_argument('--no-sandbox')
chrome_opts.add_argument('--disable-dev-shm-usage')
chrome_opts.add_argument('--remote-debugging-port=9222')
self.headless = True
# chrome_opts.add_argument("window-size=1920,1080")
# chrome_opts.add_experimental_option('w3c', False) # Needed for chromedriver 75 (logging doesn't work in w3c mode)
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['acceptInsecureCerts'] = True
print('caps')
self.driver = webdriver.Chrome(options= chrome_opts, desired_capabilities=caps)

E/launcher - unknown error: Chrome failed to start: exited abnormally, Protractor

I am new to protractor ,as well as automation testing. I ran my conf.js file but the process terminate with below error related to chorme
error message
$$> protractor conf.js
[08:38:14] I/launcher - Running 1 instances of WebDriver
[08:38:14] I/direct - Using ChromeDriver directly...
**
[08:39:14] E/launcher - unknown error: Chrome failed to start: exited
abnormally (Driver info: chromedriver=2.37.544315
(730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux
3.10.0-1062.1.1.el7.x86_64 x86_64) [08:39:14] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited
abnormally (Driver info: chromedriver=2.37.544315
(730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux
3.10.0-1062.1.1.el7.x86_64 x86_64)
**
at Object.checkLegacyResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:761:15)
at Direct.getNewDriver (/usr/lib/node_modules/protractor/built/driverProviders/direct.js:77:33)
at Runner.createBrowser (/usr/lib/node_modules/protractor/built/runner.js:195:43)
at q.then.then (/usr/lib/node_modules/protractor/built/runner.js:339:29)
at _fulfilled (/usr/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at /usr/lib/node_modules/protractor/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/usr/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /usr/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/usr/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[08:39:14] E/launcher - Process exited with error code 199
I have tried all possible solutions ,
From upgrading chrome to 59x version to downgrading it to 2.37 version
adding extras like below to conf.js file
directConnect: true,
useAllAngular2AppRoots:true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
'args':['--no-sandbox']
}
}
conf.js
exports.config = {
directConnect: true,
framework: 'jasmine',
// seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities: {
browserName: 'chrome',
chromeOptions: {
'args': ['--no-sandbox']
}
},
useAllAngular2AppRoots: true
}
could someone please help me make this work.
Thank you
(new to post questions on stackoverflow as well :b)
The main error here is that your chrome is failing to start a session. This happens if the chrome version being downloaded is the latest beta version. This is a bug in the latest protractor package which is being looked into for the protractor 6 release with backwards compatibility with webdriver-manager. For this you will have to fix the version of the chromedriver.
How are you running your webdriver manager update? Do not use the globally installed protractor to run your tests, use the protractor from node modules. Do the same thing when using webdriver manager update. Use a fix version like ./node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0 --chrome --versions.chrome=78.0.3904.97
Add this to your scripts in package.json.
Add jasmine options in your configuration file:
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 260000,
isVerbose: true,
includeStackTrace: true,
}
I don't think the latter would help but try updating the webdriver manager with the fix version and let me know how that goes.

Selenium grid not able to get it working

I've executed the following hub and node commands in my windows command prompts. I can see this is working as I get the grid console when browsing http://localhost:4441/grid/console
C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.jar -role hub -port 4441
C:\seleniumserver\java -jar selenium-server-standalone-3.4.0.ja -role wd -hub http://localhost:4441/grid/register
My automation code has the following C# code.
C# code snippet
var capabilities = DesiredCapabilities.Chrome();
capabilities.Platform = Platform.CurrentPlatform;
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);
When I run run the automation I get the following error message
Error message received
An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code
Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:4444/wd/hub/session timed out after 60 seconds.
Any suggestions what I'm doing wrong please? First time setting this up
Many thanks,
Update after comments
made the following change
var capabilities = DesiredCapabilities.Chrome();
capabilities.Platform = Platform.CurrentPlatform;
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4441/wd/hub"), capabilities);
Error message
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities) at myfile.ctor() in C:\Projects\UAT Automation\myfile.cs:line 43 at ....ctor() in C:\Projects\UAT Automation...cs:line 21
You are starting your hub in the port 4441 but you are trying to connect to 4444 using
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);
Please change your instantiation code to
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4441/wd/hub"), capabilities);
and try again.

OS X, Elixir, Ecto, Crypto, MySQL

Trying out Elixir & Ecto (not Phoenix) in a sample app to help me learn the language.
Running my program results in the following error:
=INFO REPORT==== 7-Apr-2016::16:23:28 ===
application: logger
exited: stopped
type: temporary
** (Mix) Could not start application tpos: exited in: Tpos.start(:normal, [])
** (EXIT) exited in: GenServer.call(#PID<0.164.0>, {:get_all, Tpos.Data.Models.ProfitCenter}, 5000)
** (EXIT) exited in: GenServer.call(#PID<0.163.0>, {:checkout, :run}, 5000)
** (EXIT) exited in: GenServer.call(#PID<0.168.0>, {:connect, [hostname: "localhost", timeout: 5000, otp_app: :tpos, repo: Tpos.Repo, adapter: Ecto.Adapters.MySQL, database: "tpos", username: "tpos", password: "tpos", port: 3306]}, 5000)
** (EXIT) an exception was raised:
** (UndefinedFunctionError) undefined function :crypto.hash/2 (module :crypto is not available)
(crypto) :crypto.hash(:sha, "tpos")
(mariaex) lib/mariaex/protocol.ex:150: Mariaex.Protocol.mysql_native_password/2
(mariaex) lib/mariaex/protocol.ex:47: Mariaex.Protocol.dispatch/2
(mariaex) lib/mariaex/connection.ex:284: Mariaex.Connection.process/2
(mariaex) lib/mariaex/connection.ex:251: Mariaex.Connection.handle_info/2
(stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:681: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
If I do a mix deps.clean --all and a mix.deps get and run the program again, it works. But only once. If I exit and attempt to run it again, I receive the above error.
The line that causes the error is:
data = Repo.all(ProfitCenter)
As I said, the first time through this runs fine and returns the expected data. It's only on subsequent runs that the error pops up.
From mix.exs:
defmodule Tpos.Mixfile do
use Mix.Project
def project do
[app: :tpos,
version: "0.0.1",
elixir: "~> 1.2",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps]
end
def application do
[ applications: [:mariaex, :ecto],
mod: { Tpos, [] } ]
end
defp deps do
[
{:credo, "~> 0.3", only: [:dev, :test]},
{:mariaex, "~> 0.5.0"},
{:ecto, "~> 1.1.5"},
{:exactor, "~> 2.2.0"}
]
end
end
I'm running OS X 10.11.1, and have tried several things to get it going based on advice like this.
Thoughts? Thanks!
The error states that you don't have :crypto module. You can verify that by running:
iex(1)> Application.start(:crypto)
:ok
If you get anything else than :ok, it means that your Erlang installation is not fully functional. It happens very often when you install Erlang via kerl. Kerl doesn't consider lack of openssl an error. It just skips crytpo libraries without warning.
To install fully functional Erlang with kerl you need to run:
brew install openssl
brew install unixodbc
After that create ~/.kerlrc file with following contents:
KERL_INSTALL_MANPAGES=yes
KERL_CONFIGURE_OPTIONS="--disable-hipe --enable-smp-support --enable-threads
--enable-kernel-poll --with-wx
--with-ssl=/usr/local/opt/openssl
--with-odbc=/usr/local/opt/unixodbc"
And try to reinstall Erlang. This config also adds wx-widgets which are handy if you want to run :observer application. Unixodbc also may come in handy, but less often.
If you are using different tool to install Erlang, you still need to point it to openssl path during compilation.
Alternatively, you can use packages provided by Erlang Solutions: https://www.erlang-solutions.com/resources/download.html They should install all required dependencies including crypto.

version info not a dictionary : chromeDriver : chrome 21

I am trying to run a test using webdriver on chrome. I am getting this error message.
org.openqa.selenium.WebDriverException: unknown error: version info not a dictionary
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16.84 seconds
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:53:56'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_23'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The version details are :
Chrome 21.0.1180.60
selenium-server-standalone-2.33.0
ChromeDriver 22,29,0.8 (I've tried with all three versions and getting errors).
My code is as below:
public class Testing {
public static void main(String args[]) throws Exception {
try {
System.setProperty("webdriver.chrome.driver",
"E://eclipse_workspace//testSelPro//lib//chromedriver.exe");
ChromeDriverService service = new ChromeDriverService.Builder()
.usingDriverExecutable(
new File(
"E://eclipse_workspace//testSelPro//lib//chromedriver.exe"))
.usingAnyFreePort().build();
service.start();
DesiredCapabilities capability = DesiredCapabilities.chrome();
WebDriver driver = new ChromeDriver(service, capability);
driver.get("http://www.google.com");
driver.close();
} catch (Exception e) {
System.out.println(e);
}
}
I have a limitation of running the scripts on Chrome 21 only as application is required to be certified on the same version. Also, I do not have the liberty to move to older versions of selenium as other application(s) require latest webdriver version on the framework.