Code Monkey home page Code Monkey logo

seleniumhq / selenium Goto Github PK

View Code? Open in Web Editor NEW
29.3K 1.3K 7.9K 2.08 GB

A browser automation framework and ecosystem.

Home Page: https://selenium.dev

License: Apache License 2.0

Shell 0.16% HTML 5.48% C# 15.28% JavaScript 11.08% CSS 0.01% XSLT 0.01% C++ 13.47% C 0.49% Java 34.74% Makefile 0.03% Ruby 6.60% Python 6.02% Batchfile 0.01% Ragel 0.02% Starlark 4.25% TypeScript 0.78% ASP.NET 0.01% Dockerfile 0.02% Rust 1.50% PowerShell 0.05%
selenium webdriver java ruby python javascript dotnet

selenium's Introduction

Selenium

CI

Selenium

Selenium is an umbrella project encapsulating a variety of tools and libraries enabling web browser automation. Selenium specifically provides an infrastructure for the W3C WebDriver specification — a platform and language-neutral coding interface compatible with all major web browsers.

The project is made possible by volunteer contributors who've generously donated thousands of hours in code development and upkeep.

Selenium's source code is made available under the Apache 2.0 license.

This README is for developers interested in contributing to the project. For people looking to get started using Selenium, please check out our User Manual for detailed examples and descriptions, and if you get stuck, there are several ways to Get Help.

Contributing

Please read CONTRIBUTING.md before submitting your pull requests.

Installing

These are the requirements to create your own local dev environment to contribute to Selenium.

All Platforms

  • Bazelisk, a Bazel wrapper that automatically downloads the version of Bazel specified in .bazelversion file and transparently passes through all command-line arguments to the real Bazel binary.
  • Java JDK version 17 or greater (e.g., Java 17 Temurin)
    • Set JAVA_HOME environment variable to location of Java executable (the JDK not the JRE)
    • To test this, try running the command javac. This command won't exist if you only have the JRE installed. If you're met with a list of command-line options, you're referencing the JDK properly.

MacOS

  • Xcode including the command-line tools. Install the latest version using: xcode-select --install
  • Rosetta for Apple Silicon Macs. Add build --host_platform=//:rosetta to the .bazelrc.local file. We are working to make sure this isn't required in the long run.

Windows

Several years ago Jim Evans published a great article on Setting Up a Windows Development Environment for the Selenium .NET Language Bindings; This article is out of date, but it includes more detailed descriptions and screenshots that some people might find useful.

Click to see Current Windows Setup Requirements

Option 1: Automatic Installation from Scratch

This script will ensure a complete ready to execute developer environment. (nothing is installed or set that is already present unless otherwise prompted)

  1. Open Powershell as an Administrator
  2. Execute: Set-ExecutionPolicy Bypass -Scope Process -Force to allow running the script in the process
  3. Navigate to the directory you want to clone Selenium in, or the parent directory of an already cloned Selenium repo
  4. Download and execute this script in the powershell terminal: [scripts/dev-environment-setup.ps1]`

Option 2: Manual Installation

  1. Allow running scripts in Selenium in general:
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
    
  2. Enable Developer Mode:
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"
    
  3. Install MSYS2, which is an alternative shell environment that provides Unix-like commands
    • Add bin directory to PATH environment variable (e.g., "C:\tools\msys64\usr\bin")
    • Add bash.exe location as the BAZEL_SH environment variable (e.g., "C:\tools\msys64\usr\bin\bash.exe")
  4. Install the latest version of Visual Studio Community
    • Use the visual studio installer to modify and add the "Desktop development with C++" Workload
    • Add Visual C++ build tools installation directory location to BAZEL_VC environment variable (e.g. "C:\Program Files\Microsoft Visual Studio\2022\Community\VC")
    • Add Visual C++ Build tools version to BAZEL_VC_FULL_VERSION environment variable (this can be discovered from the directory name in "$BAZEL_VC\Tools\MSVC\<BAZEL_VC_FULL_VERSION>")
  5. Add support for long file names (bazel has a lot of nested directories that can exceed default limits in Windows)
    • Enable Long Paths support with these 2 registry commands:
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor" /t REG_DWORD /f /v "DisableUNCCheck" /d "1"
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /t REG_DWORD /f /v "LongPathsEnabled" /d "1"
    • Allow Bazel to create short name versions of long file paths: fsutil 8dot3name set 0
    • Set bazel output to C:/tmp instead of nested inside project directory:
      • Create a file selenium/.bazelrc.windows.local
      • Add "startup --output_user_root=C:/tmp" to the file

Alternative Dev Environments

If you want to contribute to the project, but do not want to set up your own local dev environment, there are two alternatives available.

Using GitPod

Rather than creating your own local dev environment, GitPod provides a ready to use environment for you.

Open in Gitpod

Using Dev Container

As an alternative you can build a Dev Container - basically a docker container - suitable for building and testing Selenium using the devcontainer.json in the .devcontainer directory. Supporting IDEs like VS Code or IntelliJ IDEA should point you to how such a container can be created.

Using Docker Image

You can also build a Docker image suitable for building and testing Selenium using the Dockerfile in the dev image directory.

Building

Selenium is built using a common build tool called Bazel, to allow us to easily manage dependency downloads, generate required binaries, build and release packages, and execute tests; all in a fast, efficient manner. For a more detailed discussion, read Simon Stewart's article on Building Selenium

Often we wrap Bazel commands with our custom Rake wrapper. These are run with the ./go command.

The common Bazel commands are:

  • bazel build — evaluates dependencies, compiles source files and generates output files for the specified target. It's used to create executable binaries, libraries, or other artifacts.
  • bazel run — builds the target and then executes it. It's typically used for targets that produce executable binaries.
  • bazel test — builds and runs the target in a context with additional testing functionality
  • bazel query — identifies available targets for the provided path.

Each module that can be built is defined in a BUILD.bazel file. To execute the module you refer to it starting with a //, then include the relative path to the file that defines it, then :, then the name of the target. For example, the target to build the Grid is named executable-grid and it is defined in the 'selenium/java/src/org/openqa/selenium/grid/BAZEL.build' file. So to build the grid you would run: bazel build //java/src/org/openqa/selenium/grid:executable-grid.

The Bazel documentation has a handy guide for various shortcuts and all the ways to build multiple targets, which Selenium makes frequent use of.

To build everything for a given language:

bazel build //<language>/...

To build just the grid there is an alias name to use (the log will show where the output jar is located):

bazel build grid

To make things more simple, building each of the bindings is available with this ./go command

./go <language>:build

Developing

Java

IntelliJ

Most of the team uses Intellij for their day-to-day editing. If you're working in IntelliJ, then we highly recommend installing the Bazel IJ plugin which is documented on its own site.

To use Selenium with the IntelliJ Bazel plugin, import the repository as a Bazel project, and select the project view file from the scripts directory. ij.bazelproject for Mac/Linux and ij-win.bazelproject for Windows.

Linting

We also use Google Java Format for linting, so using the Google Java Formatter Plugin is useful; there are a few steps to get it working, so read their configuration documentation. There is also an auto-formatting script that can be run: ./scripts/format.sh

Local Installation

While Selenium is not built with Maven, you can build and install the Selenium pieces for Maven to use locally by deploying to your local maven repository (~/.m2/repository), using:

./go java:install

Updating Dependencies

Dependencies are defined in the file maven_deps.bzl. To automatically update and pin new dependencies, run:

./go java:update

Python

You can run Python code locally by updating generated files in the python directory using:

./go py:update

To install Selenium locally based on a specific commit, you can use:

./go py:install

Ruby

Instead of using irb, you can create an interactive REPL with all gems loaded using: bazel run //rb:console

If you want to debug code, you can do it via debug gem:

  1. Add binding.break to the code where you want the debugger to start.
  2. Run tests with ruby_debug configuration: bazel test --config ruby_debug <test>.
  3. When debugger starts, run the following in a separate terminal to connect to debugger:
bazel-selenium/external/bundle/bin/rdbg -A

If you want to use RubyMine for development, you can configure it use Bazel artifacts:

  1. Open rb/ as a main project directory.
  2. Run bundle exec rake update as necessary to create up-to-date artifacts. If this does not work, run ./go rb:update from the selenium (parent) directory.
  3. In Settings / Languages & Frameworks / Ruby SDK and Gems add new Interpreter pointing to ../bazel-selenium/external/rules_ruby_dist/dist/bin/ruby.
  4. You should now be able to run and debug any spec. It uses Chrome by default, but you can alter it using environment variables secified in Ruby Testing section below.

Rust

To keep Carbo.Bazel.lock synchronized with Cargo.lock, run:

CARGO_BAZEL_REPIN=true bazel sync --only=crates

Testing

There are a number of bazel configurations specific for testing.

Common Options Examples

Here are examples of arguments we make use of in testing the Selenium code:

  • --pin_browsers - run specific browser versions defined in the build (versions are updated regularly)
  • --headless - run browsers in headless mode (supported be Chrome, Edge and Firefox)
  • --flaky_test_attempts 3 - re-run failed tests up to 3 times
  • --local_test_jobs 1 - control parallelism of tests
  • --cache_test_results=no, -t- - disable caching of test results and re-runs all of them
  • --test_output all - print all output from the tests, not just errors
  • --test_output streamed - run all tests one by one and print its output immediately
  • --test_env FOO=bar - pass extra environment variable to test process
  • --run_under="xvfb-run -a" - prefix to insert before the execution

Filtering

Selenium tests can be filtered by size:

  • small — typically unit tests where no browser is opened
  • large — typically tests that actually drive a browser
  • medium — tests that are more involved than simple unit tests, but not fully driving a browser

These can be filtered using the test_size_filters argument like this:

bazel test //<language>/... --test_size_filters=small

Tests can also be filtered by tag like:

bazel test //<language>/... --test_tag_filters=this,-not-this

Java

Click to see Java Test Commands

To run unit tests:

bazel test //java/... --test_size_filters=small

To run integration tests:

bazel test //java/... --test_size_filters=medium

To run browser tests:

bazel test //java/... --test_size_filters=large --test_tag_filters=<browser>

To run a specific test:

bazel test //java/test/org/openqa/selenium/chrome:ChromeDriverFunctionalTest

JavaScript

Click to see JavaScript Test Commands

To run the tests run:

bazel test //javascript/node/selenium-webdriver:tests

You can use --test_env to pass in the browser name as SELENIUM_BROWSER.

bazel test //javascript/node/selenium-webdriver:tests --test_env=SELENIUM_BROWSER=firefox

Python

Click to see Python Test Commands

Run unit tests with:

bazel test //py:unit

To run tests with a specific browser:

bazel test //py:test-<browsername>

To run all Python tests:

bazel test //py:all

Ruby

Click to see Ruby Test Commands

Test targets:

Command Description
bazel test //rb/... Run unit, all integration tests and lint
bazel test //rb:lint Run RuboCop linter
bazel test //rb/spec/... Run unit and integration tests for all browsers
bazel test //rb/spec/... --test_size_filters small Run unit tests
bazel test //rb/spec/unit/... Run unit tests
bazel test //rb/spec/... --test_size_filters large Run integration tests for all browsers
bazel test //rb/spec/integration/... Run integration tests for all browsers
bazel test //rb/spec/integration/... --test_tag_filters firefox Run integration tests for local Firefox only
bazel test //rb/spec/integration/... --test_tag_filters firefox-remote Run integration tests for remote Firefox only
bazel test //rb/spec/integration/... --test_tag_filters firefox,firefox-remote Run integration tests for local and remote Firefox

Ruby test targets have the same name as the spec file with _spec.rb removed, so you can run them individually. Integration tests targets also have a browser and remote suffix to control which browser to pick and whether to use Grid.

Test file Test target
rb/spec/unit/selenium/webdriver/proxy_spec.rb //rb/spec/unit/selenium/webdriver:proxy
rb/spec/integration/selenium/webdriver/driver_spec.rb //rb/spec/integration/selenium/webdriver:driver-chrome
rb/spec/integration/selenium/webdriver/driver_spec.rb //rb/spec/integration/selenium/webdriver:driver-chrome-remote
rb/spec/integration/selenium/webdriver/driver_spec.rb //rb/spec/integration/selenium/webdriver:driver-firefox
rb/spec/integration/selenium/webdriver/driver_spec.rb //rb/spec/integration/selenium/webdriver:driver-firefox-remote

Supported browsers:

  • chrome
  • edge
  • firefox
  • firefox-beta
  • ie
  • safari
  • safari-preview

In addition to the Common Options Examples, here are some additional Ruby specific ones:

  • --test_arg "-tfocus" - test only focused specs
  • --test_arg "-eTimeouts" - test only specs which name include "Timeouts"
  • --test_arg "<any other RSpec argument>" - pass any extra RSpec arguments (see bazel run @bundle//bin:rspec -- --help)

Supported environment variables for use with --test_env:

  • WD_SPEC_DRIVER - the driver to test; either the browser name or 'remote' (gets set by Bazel)
  • WD_REMOTE_BROWSER - when WD_SPEC_DRIVER is remote; the name of the browser to test (gets set by Bazel)
  • WD_REMOTE_URL - URL of an already running server to use for remote tests
  • DOWNLOAD_SERVER - when WD_REMOTE_URL not set; whether to download and use most recently released server version for remote tests
  • DEBUG - turns on verbose debugging
  • HEADLESS - for chrome, edge and firefox; runs tests in headless mode
  • DISABLE_BUILD_CHECK - for chrome and edge; whether to ignore driver and browser version mismatches (allows testing Canary builds)
  • CHROME_BINARY - path to test specific Chrome browser
  • CHROMEDRIVER_BINARY - path to test specific ChromeDriver
  • EDGE_BINARY - path to test specific Edge browser
  • MSEDGEDRIVER_BINARY - path to test specific msedgedriver
  • FIREFOX_BINARY - path to test specific Firefox browser
  • GECKODRIVER_BINARY - path to test specific GeckoDriver

To run with a specific version of Ruby you can change the version in rb/.ruby-version or from command line:

echo '<X.Y.Z>' > rb/.ruby-version

.NET

Click to see .NET Test Commands

.NET tests currently only work with pinned browsers, so make sure to include that.

Run all tests with:

bazel test //dotnet/test/common:AllTests --pin_browsers=true

You can run specific tests by specifying the class name:

bazel test //dotnet/test/common:ElementFindingTest --pin_browsers=true

If the module supports multiple browsers:

bazel test //dotnet/test/common:ElementFindingTest-edge --pin_browsers=true

Rust

Click to see Rust Test Commands

Rust tests are run with:

bazel test //rust/...

Linux

Click to see Linux Testing Requirements

By default, Bazel runs these tests in your current X-server UI. If you prefer, you can alternatively run them in a virtual or nested X-server.

  1. Run the X server Xvfb :99 or Xnest :99
  2. Run a window manager, for example, DISPLAY=:99 jwm
  3. Run the tests you are interested in:
bazel test --test_env=DISPLAY=:99 //java/... --test_tag_filters=chrome

An easy way to run tests in a virtual X-server is to use Bazel's --run_under functionality:

bazel test --run_under="xvfb-run -a" //java/...

Documenting

API documentation can be found here:

To update API documentation for a specific language: ./go <language>:docs

To update all documentation: ./go all:docs

Note that JavaScript generation is currently broken.

Releasing

The full process for doing a release can be found in the wiki

Releasing is a combination of building and publishing, which often requires coordination of multiple executions and additional processing. As discussed in the Building section, we use Rake tasks with the ./go command for these things. These ./go commands include the --stamp argument to provide necessary information about the constructed asset.

You can build and release everything with:

./go all:release

To build and release a specific language:

./go <language>:release

If you have access to the Selenium EngFlow repository, you can have the assets built remotely and downloaded locally using:

./go all:release['--config', 'release']

selenium's People

Contributors

andreastt avatar automatedtester avatar barancev avatar bonigarcia avatar davehunt avatar dfabulich avatar diemol avatar eranmes avatar freynaud avatar gigix avatar harsha509 avatar hbchai avatar hugs avatar illicitonion avatar jarib avatar jimevans avatar jleyba avatar joerg1985 avatar krosenvold avatar lmtierney avatar lukeis avatar mdub avatar nirvdrum avatar p0deje avatar pujagani avatar samitbadle avatar sevaseva avatar shs96c avatar symonk avatar titusfortner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

selenium's Issues

Error in importing webdriver in selenium python

I have installed pip, selenium sucessfully but when I run python script, I am geeting erro on line "from selenium import webdriver" as ImportError: cannot import name 'webdriver'.

I recently started working on selenium python.

could you please help in resolving this issue?

selenium-webdriver (2.45) running test very slow

Today i have upgraded selenium-webdriver from 2.43 to 2.45 its really slows down the test execution.
the test use to run in 3 min 20 seconds now taking 5 minutes to run.
after switching to the old driver again test run time went back to original.

FirefoxDriver getWindowHandles sometimes returns an empty string as a window handle

I've noticed that ClickTest.testShouldOnlyFollowHrefOnce fails sometimes (but at a very low rate) because it closes the original window instead of the newly-opened window.

Specifically, this switchTo() doesn't work, so the following close() closes the "main" window, and additionally causes the switchTo() in the finally block to fail, resulting in an error like this:

java.lang.RuntimeException: org.junit.internal.runners.model.MultipleFailureException: There were 2 errors:
org.openqa.selenium.NoSuchWindowException(Unable to locate window "{a46823e9-4fa9-46de-8663-5e44cf4b2a67}"
Command duration or timeout: 2.13 seconds)
org.openqa.selenium.NoSuchWindowException(Window not found. The browser window may have been closed.
Command duration or timeout: 73 milliseconds)

From adding some logging, what's happening when the test fails is that getWindowHandles() returns two handles, one of which is the empty string. That empty string is returned by the FirefoxDriver here if win.top.fxdriver doesn't exist.

Calling getWindowHandles() again a short time later always yields two non-empty window handles.

Giving the new window a name by modifying the JS window.open call here doesn't seem to eliminate occurrences of this empty string, so perhaps this is happening if the new window hasn't finished loading yet?

A couple possible solutions that may or may not be any good (but each of which fixes the flakiness in my testing):

  1. Modify WaitingConditions.newWindowIsOpened to ignore the empty string if it's returned from getWindowHandles(). This works because the FirefoxDriver (usually on one of the next 1-2 calls to getWindowHandles) will eventually return a "real" window handle.
  2. Have FirefoxDriver ignore windows with empty names in getWindowHandles(); I suspect this isn't a great idea, because it is legal for a window name to be the empty string.
  3. Don't even return window names from getWindowHandles() -- just eliminate that branch completely; I'm not familiar with the history of the code or why the driver does this (though it has done it since at least 2009, per git blame) but I'd be curious to understand why it wouldn't work. Are there ways to create windows for which win.top.fxdriver.id will never exist, necessitating some other way of referencing the window?
  4. Do option #1 in my own copy of the code and wait for Marionette to arrive ;)

As one more footnote, I don't think I've seen this failure mode in [http://ci.seleniumhq.org:8080/](Selenium's Jenkins CI), but when I'm running the tests locally, the local and remote ends are both on the same machine (which isn't the case for the CI, AFAIU), so the low latency of sending commands to the browser might tickle the bug.

perform() explodes on webdriverjs 2.45.x

Take this simple example:

var webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
   withCapabilities(webdriver.Capabilities.chrome()).
   build();

driver.get('http://www.google.com');
var searchBox = driver.findElement(webdriver.By.name('q'));
driver.actions().mouseMove(searchBox).perform();
searchBox.sendKeys('awesome');
searchBox.getAttribute('value').then(function (value) {
  console.info('awesome');
});

driver.quit();

Run it on 2.44 and it will work just fine, fails on 2.45. Comment out the actions/perform line and it works. I have found that regardless of the placement, action, or context this command just fails now. Also this is an issue with the driver as the results are identical with every browser and versions 2.44 and 2.45 of selenium server. It also happens for every action I tried, move, click, etc

Error in this particular example:

StaleElementReferenceError: stale element reference: element is not attached to the page document
  (Session info: chrome=41.0.2272.104)
  (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Mac OS X 10.10.2 x86_64)

Though I have also seen Unknown Error: null

using latest npm @2.7.3

Happens with PYHTON 2.7.x

D:\CodeRoot\node_
lenium-webdriver\node_modules\ws\node_modules\utf-8-validate>if not de
config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\no
\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (rebuil
gyp ERR! configure error
gyp ERR! stack Error: spawn C:\Python34 ENOENT
gyp ERR! stack     at exports._errnoException (util.js:746:11)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_proce
:32)
gyp ERR! stack     at child_process.js:1137:20
gyp ERR! stack     at process._tickCallback (node.js:355:11)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\CodeRoot\node_modules\selenium-webdriver\node_modules\ws\node_modules\utf-8-valid
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
[email protected] node_modules\selenium-webdriver
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

Cannot interact with Chromium sometimes

Ubuntu 14.04 recently pushed a security update which updated Chromium and Chrome Driver from version 40.0.2214.111 to 41.0.2272.76. Ever since, I am experiencing erratic problems with reaching Chromium. Basically, what happens is that Chromium starts up but a get() does not result in any action and the associated promise is never fulfilled. I am using explicit flows.

Downgrading to the vulnerable version works but, obviously, that version is no longer in the repositories. The only alternative version would be 34.0.1847.116 which does not work with selenium-webdriver 2.44+ (timeout when trying to reach Chromium) and I am not sure what version of selenium-webdriver would be compatible with this version of Chromium.

The code roughly looks like this (in Coffeescript):

webdriver = require "selenium-webdriver"
flow = new webdriver.promise.ControlFlow().
          on "uncaughtException", (e) ->
              console.log "Uncaught exception:", e
browser = new webdriver.Builder().
                withCapabilities(webdriver.Capabilities.chrome().set("chromeOptions", {"args" : ["--incognito"]})).
                setControlFlow(flow).
                build()
browser.get "https://www.google.com"

Element not found in the cache

Hi Folks,
I am new to GUI based automation Testing.

Can somebody explain me what can cause the following exception.

I thought it may be due to some time constraints so I have used expilicit wait in my Java-Selenium prog
but i was not able to resolve this issue.

org.openqa.selenium.StaleElementReferenceException: Element not found in the cache - perhaps the page has changed since it was looked up

Provide a way to change root path for tmp files.

Selenium typically writes Firefox profile files in /tmp/ as temporary directory (/tmp/tmpXXXXXX).

This is OK as long as everything goes well and driver.quit() is called, cleaning the directories.

In my case, selenium is running under Xvfb, managed by a supervisord, and it looks like in some cases, my files are not cleaned. It would be cool to store all this tmp files elsewhere, so I can easily rm -fr them.

My supervisord config, FYI looks like:

[program:tests-example-com]
user=nobody
command=/home/.../test.py -v run-with-browser http://www.example.com/what-to-test/
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
stopsignal=QUIT

My python code, FYI looks like a context manager to be sure to not forgot driver.quit.:

[...]
class WhateverTester:
[...]
    def __enter__(self):
        return self

    def __exit__(self, type, value, traceback):
        self.driver.quit()
[...]
    with WhateverTester(endpoint) as tester:
        tester.run()
[...]

WebDriverJS - capabilities.merge does not merge child objects

For example, if one capabilities object is

chromeOptions: {
  args: '--foo'
}

and the other is

chromeOptions: {
  binary: '/path/to/chrome'
}

then capabilities.merge will override the entire chromeOptions object instead of combining into one with both properties.

I'm not sure if this is working as intended or not, but it's causing some unexpected effects when merging.

IEDriverServer: no error reported in case of failed javascript execution

When using synthetic events, the command execution of sendKeys command sometimes fails because the javascript could not be executed.
Although the failure is detected (see the log excerpt), the response status is set to 0, indicating success.
Therefor org.openqa.selenium.remote.RemoteWebDriver.execute will not throw an exception

T 2015-03-26 01:00:24:008 server.cc(370) Entering Server::SendResponseToClient
T 2015-03-26 01:00:24:008 response.cc(33) Entering Response::Deserialize
T 2015-03-26 01:00:24:008 server.cc(424) Entering Server::SendHttpOk
T 2015-03-26 01:00:24:008 server.cc(136) Entering Server::ProcessRequest
T 2015-03-26 01:00:24:008 server.cc(200) Entering Server::ReadRequestBody
T 2015-03-26 01:00:24:008 server.cc(145) Process request with: URI: /session/f79dbb70-5180-4eaf-90f3-ad1c3c87ad6e/element/0dfbc107-e8a5-420a-87f8-42fc821d23a0/value HTTP verb: POST
body: {"id":"0dfbc107-e8a5-420a-87f8-42fc821d23a0","value":[""]}
T 2015-03-26 01:00:24:008 server.cc(234) Entering Server::DispatchCommand
T 2015-03-26 01:00:24:008 server.cc(541) Entering Server::LookupCommand
D 2015-03-26 01:00:24:008 server.cc(243) Command: POST /session/f79dbb70-5180-4eaf-90f3-ad1c3c87ad6e/element/0dfbc107-e8a5-420a-87f8-42fc821d23a0/value {"id":"0dfbc107-e8a5-420a-87f8-42fc821d23a0","value":[""]}
T 2015-03-26 01:00:24:008 server.cc(357) Entering Server::LookupSession
T 2015-03-26 01:00:24:008 IESession.cpp(212) Entering IESession::ExecuteCommand
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(158) Entering IECommandExecutor::OnSetCommand
T 2015-03-26 01:00:24:008 command.cc(28) Entering Command::Deserialize
D 2015-03-26 01:00:24:008 command.cc(33) Raw JSON command: { "name" : "sendKeys", "locator" : { "sessionid" : "f79dbb70-5180-4eaf-90f3-ad1c3c87ad6e", "id" : "0dfbc107-e8a5-420a-87f8-42fc821d23a0" }, "parameters" : {"id":"0dfbc107-e8a5-420a-87f8-42fc821d23a0","value":[""]} }
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(169) Entering IECommandExecutor::OnExecCommand
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(470) Entering IECommandExecutor::DispatchCommand
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(586) Entering IECommandExecutor::GetCurrentBrowser
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(592) Entering IECommandExecutor::GetManagedBrowser
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(542) Entering IECommandExecutor::IsAlertActive
T 2015-03-26 01:00:24:008 Browser.cpp(679) Entering Browser::GetActiveDialogWindowHandle
T 2015-03-26 01:00:24:008 Browser.cpp(192) Entering Browser::GetContentWindowHandle
D 2015-03-26 01:00:24:008 IECommandExecutor.cpp(556) No alert handle is found
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(586) Entering IECommandExecutor::GetCurrentBrowser
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(592) Entering IECommandExecutor::GetManagedBrowser
T 2015-03-26 01:00:24:008 Browser.cpp(192) Entering Browser::GetContentWindowHandle
T 2015-03-26 01:00:24:008 Browser.cpp(402) Entering Browser::GetTopLevelWindowHandle
T 2015-03-26 01:00:24:008 IESession.cpp(233) Beginning wait for response length to be not zero
T 2015-03-26 01:00:24:008 IECommandHandler.cpp(37) Entering IECommandHandler::GetElement
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(679) Entering IECommandExecutor::GetManagedElement
T 2015-03-26 01:00:24:008 ElementRepository.cpp(28) Entering ElementRepository::GetManagedElement
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(586) Entering IECommandExecutor::GetCurrentBrowser
T 2015-03-26 01:00:24:008 IECommandExecutor.cpp(592) Entering IECommandExecutor::GetManagedBrowser
T 2015-03-26 01:00:24:008 Browser.cpp(112) Entering Browser::GetDocument
I 2015-03-26 01:00:24:008 Browser.cpp(116) No child frame focus. Focus is on top-level frame
T 2015-03-26 01:00:24:018 Browser.cpp(579) Entering Browser::GetDocumentFromWindow
T 2015-03-26 01:00:24:018 Element.cpp(81) Entering Element::IsDisplayed
T 2015-03-26 01:00:24:018 Element.cpp(896) Entering Element::GetContainingDocument
T 2015-03-26 01:00:24:018 Script.cpp(41) Entering Script::Initialize
T 2015-03-26 01:00:24:018 Script.cpp(91) Entering Script::AddArgument(IHTMLElement*)
T 2015-03-26 01:00:24:018 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:018 Script.cpp(80) Entering Script::AddArgument(bool)
T 2015-03-26 01:00:24:018 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:018 Script.cpp(161) Entering Script::Execute
T 2015-03-26 01:00:24:018 Script.cpp(469) Entering Script::CreateAnonymousFunction
T 2015-03-26 01:00:24:038 Element.cpp(125) Entering Element::IsEnabled
T 2015-03-26 01:00:24:038 Element.cpp(896) Entering Element::GetContainingDocument
T 2015-03-26 01:00:24:038 Script.cpp(41) Entering Script::Initialize
T 2015-03-26 01:00:24:038 Script.cpp(91) Entering Script::AddArgument(IHTMLElement*)
T 2015-03-26 01:00:24:038 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:038 Script.cpp(161) Entering Script::Execute
T 2015-03-26 01:00:24:038 Script.cpp(469) Entering Script::CreateAnonymousFunction
T 2015-03-26 01:00:24:048 Element.cpp(302) Entering Element::GetLocationOnceScrolledIntoView
T 2015-03-26 01:00:24:048 Element.cpp(433) Entering Element::GetLocation
T 2015-03-26 01:00:24:048 Element.cpp(569) Entering Element::IsInline
D 2015-03-26 01:00:24:048 Element.cpp(479) Element is a block element, using IHTMLElement2::getBoundingClientRect
T 2015-03-26 01:00:24:058 Element.cpp(590) Entering Element::RectHasNonZeroDimensions
T 2015-03-26 01:00:24:058 Element.cpp(606) Entering Element::GetFrameDetails
T 2015-03-26 01:00:24:058 Element.cpp(896) Entering Element::GetContainingDocument
D 2015-03-26 01:00:24:068 Element.cpp(556) Element is not in a frame
T 2015-03-26 01:00:24:068 Element.cpp(845) Entering Element::CalculateClickPoint
T 2015-03-26 01:00:24:068 Element.cpp(784) Entering Element::GetClickableViewPortLocation
T 2015-03-26 01:00:24:068 Element.cpp(896) Entering Element::GetContainingDocument
T 2015-03-26 01:00:24:068 DocumentHost.cpp(401) Entering DocumentHost::GetDocumentMode
T 2015-03-26 01:00:24:068 Element.cpp(871) Entering Element::IsLocationInViewPort
T 2015-03-26 01:00:24:068 Element.cpp(784) Entering Element::GetClickableViewPortLocation
T 2015-03-26 01:00:24:068 Element.cpp(896) Entering Element::GetContainingDocument
T 2015-03-26 01:00:24:068 DocumentHost.cpp(401) Entering DocumentHost::GetDocumentMode
T 2015-03-26 01:00:24:078 Element.cpp(369) Entering Element::IsHiddenByOverflow
T 2015-03-26 01:00:24:078 Element.cpp(896) Entering Element::GetContainingDocument
T 2015-03-26 01:00:24:078 Script.cpp(41) Entering Script::Initialize
T 2015-03-26 01:00:24:078 Script.cpp(91) Entering Script::AddArgument(IHTMLElement*)
T 2015-03-26 01:00:24:078 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:078 Script.cpp(161) Entering Script::Execute
T 2015-03-26 01:00:24:078 Script.cpp(469) Entering Script::CreateAnonymousFunction
T 2015-03-26 01:00:24:098 Script.cpp(425) Entering Script::ConvertResultToString
D 2015-03-26 01:00:24:098 Script.cpp(436) Result type is string
D 2015-03-26 01:00:24:098 Element.cpp(348) (x, y, w, h): 159, 228, 398, 20
T 2015-03-26 01:00:24:108 InputManager.cpp(62) Entering InputManager::PerformInputSequence
D 2015-03-26 01:00:24:108 InputManager.cpp(83) Mutex acquired for user interaction.
T 2015-03-26 01:00:24:108 InputManager.cpp(235) Entering InputManager::SetFocusToBrowser
T 2015-03-26 01:00:24:108 Browser.cpp(192) Entering Browser::GetContentWindowHandle
T 2015-03-26 01:00:24:108 Browser.cpp(402) Entering Browser::GetTopLevelWindowHandle
T 2015-03-26 01:00:24:108 Browser.cpp(402) Entering Browser::GetTopLevelWindowHandle
T 2015-03-26 01:00:24:108 InputManager.cpp(551) Entering InputManager::SendKeystrokes
D 2015-03-26 01:00:24:108 InputManager.cpp(577) Using synthetic events for sending keys
T 2015-03-26 01:00:24:108 Browser.cpp(112) Entering Browser::GetDocument
I 2015-03-26 01:00:24:108 Browser.cpp(116) No child frame focus. Focus is on top-level frame
T 2015-03-26 01:00:24:128 Browser.cpp(579) Entering Browser::GetDocumentFromWindow
T 2015-03-26 01:00:24:128 Script.cpp(41) Entering Script::Initialize
T 2015-03-26 01:00:24:128 Script.cpp(104) Entering Script::AddNullArgument
T 2015-03-26 01:00:24:128 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:128 Script.cpp(62) Entering Script::AddArgument(std::wstring)
T 2015-03-26 01:00:24:128 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:128 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:128 Script.cpp(80) Entering Script::AddArgument(bool)
T 2015-03-26 01:00:24:128 Script.cpp(97) Entering Script::AddArgument(VARIANT)
T 2015-03-26 01:00:24:128 Script.cpp(161) Entering Script::Execute
T 2015-03-26 01:00:24:128 Script.cpp(469) Entering Script::CreateAnonymousFunction

**D 2015-03-26 01:00:24:158 Script.cpp(241) -2147352319 [Unknown error 0x80020101]: Failed to execute anonymous function, no exception information retrieved
W 2015-03-26 01:00:24:158 InputManager.cpp(598) Unable to execute js to send keystrokes**
T 2015-03-26 01:00:24:158 response.cc(60) Entering Response::SetSuccessResponse
T 2015-03-26 01:00:24:158 response.cc(66) Entering Response::SetResponse
T 2015-03-26 01:00:24:158 IECommandExecutor.cpp(586) Entering IECommandExecutor::GetCurrentBrowser
T 2015-03-26 01:00:24:158 IECommandExecutor.cpp(592) Entering IECommandExecutor::GetManagedBrowser
T 2015-03-26 01:00:24:158 response.cc(48) Entering Response::Serialize
T 2015-03-26 01:00:24:158 IESession.cpp(242) Found non-zero response length
T 2015-03-26 01:00:24:158 IECommandExecutor.cpp(192) Entering IECommandExecutor::OnGetResponse
T 2015-03-26 01:00:24:158 IECommandExecutor.cpp(307) Entering IECommandExecutor::OnIsSessionValid
**D 2015-03-26 01:00:24:158 server.cc(317) Response: {"sessionId":"f79dbb70-5180-4eaf-90f3-ad1c3c87ad6e","status":0,"value":null}**

Python Selenium 2.45 appears broken with Firefox 36.0.4

Attempts to start the driver with self.driver = webdriver.Firefox() fails with

ERROR:root:Message: "Can't load the profile. Profile Dir: c:\\users\\martin~1\\appdata\\local\\temp\\tmpldmwnd Firefox output: None" 
Traceback (most recent call last):
  File "C:\Python\SeaMonsters\test\acceptance\__init__.py", line 63, in setUp
    self.driver = webdriver.Firefox()
  File "C:\Python\SeaMonsters\env\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 59, in __init__
    self.binary, timeout),
  File "C:\Python\SeaMonsters\env\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "C:\Python\SeaMonsters\env\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 64, in launch_browser
    self._wait_until_connectable()
  File "C:\Python\SeaMonsters\env\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 108, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))

Firefox: synthetic keyboard events do not set KeyboardEvent.key property properly

Selenium 2.45.0 uses synthetic keyboard events for Firefox 36.0.4 on all(?) platforms. These synthetic keyboard events set the javascript KeyboardEvent.key property always to 'Unidentified' instead of the expected character.

Using native events with Firefox <= 34.0.5 on Windows 7 the following phpunit test run successfully:

<?php
class KeyTest extends PHPUnit_Extensions_Selenium2TestCase
{
    protected function setUp()
    {
        $this->setBrowser('firefox');
        $this->setHost('localhost');
        $this->setBrowserUrl('http://unixpapa.com/js/testkey.html');
    }

    public function testKeys()
    {
        $this->url('http://unixpapa.com/js/testkey.html');

        $this->byName('classic')->click();
        $this->byName('dom3')->click();

        $this->keys('z');
        $this->assertContains('key=z', $this->byTag('textarea')->value());
    }
}

As far as I can see, it's related to the use of sendKeyEvent in favour to sendNativeKeyEvent in

return windowUtils.sendKeyEvent(type, keyCode, charCode, modifiers, additionalFlags);
.

While testing sendNativeKeyEvent in Firefox's Scratchpad I had mixed results:

  • Windows: working
  • Linux: Exception
  • MacOS: obviously working (key is send to scratchpad window instead of webpage)

[C#] SelectElement does not give access to base element functionality

Hi!
Right now, SelectElement does not give access to the base element's functionality. Eg. even if you need to access simple stuff as the "Displayed" property of the base element, you have to provide them separately in your PageObjects.

public IWebElement SelectBase // returns base iwebelement for checks
public SelectElement Select // wraps around SelectBase

It would be nice to make the base element accessible either through some property, or by implementing IWebElement on SelectElement (which then passes the calls on to base element essentailly)

I did the 2nd in https://github.com/FrankyBoy/selenium/commit/88ce778e3aebbced514fc522a6eed34dbac7814f to see how hard it would be, and its really just boring boilerplate.

Unable to get pop up after uploading a file using AutoIt

Scenario: After uploading an invalid file (apart from image file) using AutoIt, pop up is not displaying. Uploading a proper file (any image file) works fine

Browser: Firefox 34.0.5
Selenium Library Version: selenium-server-standalone-2.42.2
Autoit: autoit-v3

Steps:

  1. The test is performed on "www.pspsrint.com" portal using Guest account
  2. When I try to click on any product e.g "Business Card" and try to upload invalid file I don't get an error popup

My Code is as below

public static WebDriver openfirefox;
@test(priority = 1)
public void openLink() {
openfirefox.get(https://www.psprint.com/);//Opens the URL
openfirefox.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);// Wait
}
@test(priority = 2)
public void upload() throws InterruptedException {
if(isElementPresent(By.id("fileupload_front1"))) {
upload("front");
}
}

private void upload(String side) {
WebElement error = openfirefox.findElement(By.xpath(Constant.CloseError));
if(side == "front"){
openfirefox.findElement(By.id("fileupload_front1")).click();// Clicks on Upload now button
Runtime.getRuntime().exec(Constant.UploadPath);
openfirefox.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
if(error.isDisplayed()) {
openfirefox.findElement(By.xpath(CloseError)).click();//Close the error window
}
}

Node config "chrome_binary" causes an exception when ChromeOptions capability is set

Driver initialization code:

DesiredCapabilities dc = new DesiredCapabilities();
dc.setBrowserName('chrome');
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
dc.setCapability(ChromeOptions.CAPABILITY, options)
RemoteWebDriver driver = new RemoteWebDriver(new URL('http://localhost:4444/wd/hub'), dc);

nodeconfig.json code:

"browserName": "chrome",
"chrome_binary": "C:\\Tools\\GoogleChromePortable\\App\\Chrome-bin\\chrome.exe"
Exception:
 org.openqa.grid.common.exception.GridException: Error forwarding the new session The listener threw an exception ( listener bug )
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:114)
    at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
    at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
    at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
    at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
    at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
    at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
    at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)

I believe it has something to do with DefaultRemoteProxy.java code:

      if (BrowserType.CHROME.equals(cap.get(CapabilityType.BROWSER_NAME))) {
        if (session.getSlot().getCapabilities().get("chrome_binary") != null) {
          JsonObject options = (JsonObject) cap.get(ChromeOptions.CAPABILITY);
          if (options == null) {
            options = new JsonObject();
          }
          options.addProperty("binary", (String) session.getSlot().getCapabilities().get("chrome_binary"));
          cap.put(ChromeOptions.CAPABILITY, options);
        }

Removed "chrome_binary" from nodeconfig.json - no exception, "start-maximized" passed fine.
Removed dc.setCapability(ChromeOptions.CAPABILITY, options) line - no exception, "chrome_binary" works fine.

Webdriver hangs for ~1 minute even if chromedriver exits immediately

This isn't a direct problem with webdriver, but it does make diagnosing other problems harder. I had a bug in my chromedriver wrapper script, and it was exiting immediately. But webdriver will hang for a minute before reporting a problem, and will just report a timeout, not that the chromedriver failed/exited.

I believe the core of the problem is in javascript/node/selenium-webdriver/remote/index.js where the command.result().then handler will not kick the httpUtil.waitForServer in the case the command exits early/immediately.

The patch below demonstrates the problem by adding a test for using /bin/false as the chromedriver. It times out after a minute.

diff --git a/javascript/node/selenium-webdriver/test/chrome/options_test.js b/javascript/node/selenium-webdriver/test/chrome/options_test.js
index eab3070..39524b9 100644
--- a/javascript/node/selenium-webdriver/test/chrome/options_test.js
+++ b/javascript/node/selenium-webdriver/test/chrome/options_test.js
@@ -204,7 +204,7 @@ test.suite(function(env) {
     driver.quit();
   });

-  describe('Chrome options', function() {
+  describe.only('Chrome options', function() {
     test.it('can start Chrome with custom args', function() {
       var options = new chrome.Options().
           addArguments('user-agent=foo;bar');
@@ -219,5 +219,16 @@ test.suite(function(env) {
           'return window.navigator.userAgent');
       assert(userAgent).equalTo('foo;bar');
     });
+
+    test.it('can catch bad startup script', function() {
+      var options = new chrome.Options().
+        setChromeBinaryPath('/bin/false');
+
+      driver = env.builder().
+          setChromeOptions(options).
+          build();
+
+      driver.get('nothing');
+    });
   });
 }, {browsers: ['chrome']});

Unnecessary lock.unlock() in FirefoxDriver.java

I believe that there is unnecessary lock.unlock() method call in org.openqa.selenium.firefox.FirefoxDriver.java (selenium/java/client/src/org/openqa/selenium/firefox/FirefoxDriver.java) at line 282 in finally block. lock.lock(..) is never called before said unlock.

According to file history it was necessary earlier when lock was actually locked before that unlock. But now locking is performed in NewProfileExtensionConnection in start() method.

How to get the output of the browser's console?

Is there a command to retrieve the browser's console output? This for various log levels, preferable as an event?

This feature has been raised in the WebdriverIO repository at webdriverio/webdriverio#464 but it seems that this is rather a Selenium thing.

Let me know if this is already implemented or on your todo list. Thanks

Possible memory leak?

Hello

I am using selenium through ruby's selenium-webdriver to create a bot, which plays a browser game for me (single player browser game, no cheating here; ) ). The problem is, that process gains memory with time, and after 3, 4 hours it needs a restart, because of memory usage and slowing down. I managed to get a profile in firefox during the increased memory time and most of the time seems to be spent in selenium internals, namely in

Connection.prototype.close

in javascript.

What I do: I create a driver object in ruby and perform some actions in infinite loop. The code is available here: https://github.com/KillaPL/automaton.

Is this possibly a memory leak in selenium internals? I am not closing the connection myself anywhere. If so, what can I do more to help fix it? If not, what am I doing wrong?

To reproduce the issue, clone the https://github.com/KillaPL/automaton, bundle install and run it. It might fail on first run, it's not bulletproof yet. It will slowly, but steadily gain memory.

Profile file from firefox I used is available here: http://speedy.sh/Dgewu/profile.json

Nodes are not reading hub's configuration during re-registering

Reproduced with Selenium 2.45
HUB: Linux, Ubuntu
Node: Windows 8, Chrome

Steps to reproduce:
1) Start Selenium Grid. Let say, only 2 stations: HUB and NODE.
For HUB, set timeouts, as:
"timeout": 20000
"browserTimeout": 20000
For NODE do not set any timeouts explicitly.
2) Run this code against Grid:

driver.get(url);
sleep(30000);
driver.get(url);

It fails with org.openqa.selenium.remote.SessionNotFoundException.
This line added to the NODE log:
INFO org.openqa.selenium.remote.server.DriverServlet - Session 7f5fffec-4882-4c4c-b091-c780c66d379d deleted due to client timeout
3) So, trying to resolve issue, increase timeouts on the HUB:
"timeout": 40000
"browserTimeout": 40000
Restart HUB. NODE would re-register automatically.

Defect:
Code still fails. Timeout still set at 20 seconds. But, if you look at the Grid console, it would show new (updated) configuration, which is misleading.
The reason: NODE haven't read new timeouts from the HUB.
NODE will only read that new configuration, when re-started.

Expected:
NODE would read configuration from the HUB, when re-registering.

Update KB3032359 breaking IE driver

The KB3032359 update from march 10 breaks the Internet Explorer driver.

Environment:
Windows 8.1 64bit, IE11, IEDriver 32bit 2.45

To reproduce:

var driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl(@"http://www.google.com");
driver.FindElementByName("q").SendKeys("ok");

The last line throws ElementNotFoundException and the log indicates an "Access denied" error on IHTMLWindow2::execScript.
It seems to be related to execScript being deprecated:
https://connect.microsoft.com/IE/feedback/details/1062093/installation-of-kb3025390-breaks-out-of-process-javascript-execution-in-ie11

I have the registry key "FEATURE_DISABLE_INTERNAL_SECURITY_MANAGER" set to 1,
but this workaround for the kb3025390 doesn't work with this new update.

Clicking Invisible option elements should not succeed (from google code #8563)

example html:

<select>
<option value="option0">option0</option>
<option value="option1" disabled="disabled">Disabled option</option>
<option value="option2" style="visibility: hidden;">Option hidden</option>
<option value="option3" style="display: none;">Option display none</option>
</select>

options = driver.find_elements_by_tag_name("option")

options[0].click(); <- behaves as expected
options[1].click(); <- does a no-op (expected behavior IMO)
options[2].click(); chrome renders this option, firefox doesn't. Firefox doesn't allow the user to select this, but WebDriver will select this option with this call.
options[3].click(); <- no one renders this option and it isn't settable by a user... yet webdriver sets it (and thus updates the rendered UI)

Related W3C WebDriver spec bug - https://www.w3.org/Bugs/Public/show_bug.cgi?id=28143

Selenium IDE - Scheduler icon tool tip a little confusing.

Thanks so much for the new Selenium IDE Scheduler... I'm really enjoying using it.

One suggestion, the clock tooltip reads "Turn test scheduler on/off" whether it is currently on or off. It would be great if the tooltip would make it clear which state it is in. I like how the Record icon tool tip reads either "Click to Record" or "Now Recording, Click to Stop Recording".

How about something like:

  • "Click to turn Scheduler on"
  • "Scheduler now on, Click to turn Scheduler off"

Thanks,
Jeff

[WebDriverJS] - driver.wait behavior when timeout = 0 is confusing

With version 2.45.1, the behavior when the timeout is unset for driver.wait is confusing. It will wait indefinitely if the condition is a promise, but waits for a time of 0 if the condition is a function:

var promise = require('selenium-webdriver').promise;

var donePromise = promise.delayed(1000);
promise.controlFlow().wait(donePromise); // This waits just fine.

var done = false;
setTimeout(function() {
  done = true;
}, 1000);

promise.controlFlow().wait(function() {
  return done;
}); // This times out and throws an error.

Should a timeout of 0 also cause wait to wait indefinitely if the condition is a function?

firefox node raises exception when starting test session

I am using the docker containers (2.45.0) to create a grid.

On the same host machine I run:

docker run -d -p 4444:4444 --name selenium-hub selenium/hub:2.45.0
docker run --rm --name=ff --link selenium-hub:hub selenium/node-firefox:2.45.0

The node registers properly. However once I start a test run, I see the exception below in the log. It's happening right as I attempt to create the remote webdriver.

browser = webdriver.Remote('http://client:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX)

FWIW - the chromedriver node runs perfectly.

20:01:01.356 INFO - Registering the node to hub :http://172.17.0.21:4444/grid/register
20:01:13.949 INFO - Executing: [new session: Capabilities [{firefox_profile=UEsDBBQAAAAIACZoeEZh7yP8ZwMAA..., platform=ANY, javascriptEnabled=true, browserName=firefox, proxy={httpProxy=172.28.128.11:9923, sslProxy=172.28.128.11:9923, proxyType=MANUAL}, version=}]])
20:01:13.974 INFO - Creating a new session for Capabilities [{firefox_profile=UEsDBBQAAAAIACZoeEZh7yP8ZwMAA..., platform=ANY, javascriptEnabled=true, browserName=firefox, proxy={httpProxy=172.28.128.11:9923, sslProxy=172.28.128.11:9923, proxyType=MANUAL}, version=}]
20:01:59.418 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'fa59fe32da9b', ip: '172.17.0.23', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-46-generic', java.version: '1.7.0_75'
Driver info: driver.version: unknown
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:175)
    at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSession.java:111)
    at org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:88)
    at org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:109)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:57)
    at org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:110)
    at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:172)
    at org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:201)
    at org.openqa.selenium.remote.server.DriverServlet.doPost(DriverServlet.java:163)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at org.openqa.selenium.remote.server.DriverServlet.service(DriverServlet.java:129)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.openqa.jetty.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
    at org.openqa.jetty.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:680)
    at org.openqa.jetty.jetty.servlet.ServletHandler.handle(ServletHandler.java:571)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1526)
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1479)
    at org.openqa.jetty.http.HttpServer.service(HttpServer.java:920)
    at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
    at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
    at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
    at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
    at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:358)
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:537)
Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'fa59fe32da9b', ip: '172.17.0.23', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-46-generic', java.version: '1.7.0_75'
Driver info: driver.version: unknown
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:69)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.newInstance(DefaultDriverProvider.java:53)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:54)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:214)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:168)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.server.DefaultDriverProvider.callConstructor(DefaultDriverProvider.java:59)
    ... 9 more
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/usr/bin/firefox) on port 7055; process output follows:

(process:40): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Xlib:  extension "RANDR" missing on display ":99".
process 40: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/etc/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.

Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'fa59fe32da9b', ip: '172.17.0.23', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-46-generic', java.version: '1.7.0_75'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:134)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
    ... 14 more
Caused by: org.openqa.selenium.WebDriverException: java.lang.InterruptedException: Process timed out after waiting for 45000 ms.
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'fa59fe32da9b', ip: '172.17.0.23', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-46-generic', java.version: '1.7.0_75'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.os.CommandLine.waitFor(CommandLine.java:131)
    at org.openqa.selenium.firefox.FirefoxBinary.waitFor(FirefoxBinary.java:222)
    at org.openqa.selenium.firefox.FirefoxBinary.clean(FirefoxBinary.java:242)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:91)
    ... 19 more
Caused by: java.lang.InterruptedException: Process timed out after waiting for 45000 ms.
    at org.openqa.selenium.os.UnixProcess.waitFor(UnixProcess.java:148)
    at org.openqa.selenium.os.CommandLine.waitFor(CommandLine.java:129)
    ... 22 more
20:01:59.423 WARN - Exception: Process timed out after waiting for 45000 ms.
20:01:59.505 INFO - Executing: [new session: Capabilities [{firefox_profile=UEsDBBQAAAAIAD1oeEZh7yP8ZwMAA..., platform=ANY, javascriptEnabled=true, browserName=firefox, proxy={httpProxy=172.28.128.11:9923, sslProxy=172.28.128.11:9923, proxyType=MANUAL}, version=}]])
20:01:59.509 INFO - Creating a new session for Capabilities [{firefox_profile=UEsDBBQAAAAIAD1oeEZh7yP8ZwMAA..., platform=ANY, javascriptEnabled=true, browserName=firefox, proxy={httpProxy=172.28.128.11:9923, sslProxy=172.28.128.11:9923, proxyType=MANUAL}, version=}]

[C#] SelectElement.SelectedOption slow on big lists

Hi!

The current implementation of the SelectedOption property is quite slow (because it checks each element in turn). Because of this a colleague of mine implemented an extension method which (he claims). The replacement code is simply as such:

return _element.FindElement(By.CssSelector("option[selected]"))

AllSelectedOptions could be adapted in a similar manner (i.e. FindElements with same selector).
Let me know if that solution actually works or if its just a "common special case" kind of thing.

Cheers!

ExpectedConditions.not is not working correctly

Details of the setup used to test this:

Windows 7
ChromeDriver (chrome ver 41)
Java bindings, selenium version 2.44.0

Java and html+js code to reproduce the issue: https://gist.github.com/anonymous/c81bb74d9bbcd94b0398

What should happen: The test should pass as the div with id 'woop' is being removed via assigning the innerHTML.
What happens: The wait times out after waiting for the ExpectedConditions specified (for the element with id 'woop' to not be present).

You can see the same behaviour with visibilityOfElementLocated and using ExpectedConditions.not - here it's even more obvious that this is broken as using invisibilityOfElementLocated works just fine where using ExpectedConditions.not(ExpectedConditions.visibilityOfElementLocated) doesn't.

Browser window stops responding after driver process dies

Hi Selenium Devs,
I am using chromedriver and ran into the problem of process dying which results in the browser window to stop responding. I filed a bug with the chromedriver project but they referred me here. To see the actual thread please go here

To reproduce:
fire up a chrome window via chromedriver
kill the chromedriver process manually
try navigating to another url

I tried to check for if driver == null or call driver.getUrl() but that does not seem to work either.

Ideally there should be an exception thrown if the driver process was killed

Robotframework Selenium2library and checkbox followed by a textbox.

I have a webpage whose structure looks like this
[checkbox1]
[some text1] [textbox1]
[checkbox2]
[some text2] [textbox2]

I am trying to find a logic where, if i click on checkbox1, textbox1 should be focused and allow me to enter text, if checkbox2 is checked, when i enter text, it should automatically fill in textbox2.

Can someone please help

Looping over Elements and performing actions gets exponentially slower as the list grows (Java binding web driver 2.45.0)

Version: 2.45.0
Bindings: Java
Browser: Chrome/FF

While the findElementsBy function takes only mere seconds to return a record set, selenium slows down at an exponential rate when performing actions on the record set.

Case in point, I have to loop over 1000 elements and perform a click on each. The findElementsBy function only takes 6 seconds to get all 1000 WebElements, however, looping over each and performing a click takes hours and gets exponentially slower as the iterator processes.

It seems there is a memory leak issue here because even simply grabbing the first element in the list and performing a click on just that element takes 30+ seconds.

When doing a singular findElementBy().click(), the action performs instantly.

I also performed a test by looping over each and simply outputting getText(). You can see as the iterator moves through that each subsequent iteration is twice as slow as the previous.

I also performed another test by getting my 1000 elements. But then I simply called findElement singular again to grab the first element and performed a click. The click still took 30+ seconds. So it seems as though there is definitely a memory issue here.

Grid2. SelfRegisteringRemote. Incorrect processing of the "timeout" optional parameter

Selenium Grid2 Wiki page says:

-timeout 30 (300 is default) The timeout in seconds ...

But in SelfRegisteringRemote.java source file, at line 97 we have divide by 1000 as if we're using the value of the "-timeout" parameter in milliseconds:

    if (hubParameters.has(CLIENT_TIMEOUT)){
        int timeout = hubParameters.get(CLIENT_TIMEOUT).getAsInt() / 1000;
        remoteControlConfiguration.setTimeoutInSeconds(timeout);
    }

We should either to update source code or documentation.

Windows7-SeleniumIDE2.9.0-Javascript errors

After installing a new version of IDE (2.9.0) on FF 36.0.4 on a windows seven machine, I'm am getting an endless stream of error popups, if I open the actions or the options drop-down. I am also seeing what another user reported: "Table view is not available with this format" Examples below:

  1. There was an unexpected error. Msg: TypeError: editor.app is undefined
    Url: chrome://selenium-ide/content/editor.js, line: 1007, column: 74
    Editor.prototype.onPopupOptions@chrome://selenium-ide/content/editor.js:1007:75
    onpopupshowing@chrome://selenium-ide/content/selenium-ide.xul:1:1
  2. There was an unexpected error. Msg: TypeError: this.app is undefined
    Url: chrome://selenium-ide/content/editor.js, line: 1054, column: 2
    Editor.prototype.getTestCase@chrome://selenium-ide/content/editor.js:1054:3
    Editor.prototype.tabSelected@chrome://selenium-ide/content/editor.js:601:7
    onselect@chrome://selenium-ide/content/selenium-ide.xul:1:22
    set_selectedIndex@chrome://global/content/bindings/tabbox.xml:406:15
    set_selectedItem@chrome://global/content/bindings/tabbox.xml:431:34
    _selectNewTab@chrome://global/content/bindings/tabbox.xml:476:11
    onxblmousedown@chrome://global/content/bindings/tabbox.xml:771:11
    seleniumscreenshot

javascript interface not working with setTimeout

e.g.

var fs = require('fs');
var webdriver = require('selenium-webdriver');

var remote = new webdriver
  .Builder()
  .withCapabilities({ browserName: 'phantomjs' })
  .build();

remote.manage().window().setSize(1024, 900);

remote.get('http://google.com');

setTimeout(function() {
  remote.executeScript('return true').then(log, onError);
}, 500);

function log(res) { console.log(res); }

function onError(e) { throw e; }

This small program gets stuck and never ends, but it we move the line remote.executeScript('return true').then(log, onError); out of the setTimeout callback then it starts working as expected.

Shouldn't the executeScript call schedule the operation regardless of when it is called?

I'm using [email protected]

FirefoxDriver with C# / Mono does not work

There is actually an existing bug report (https://code.google.com/p/selenium/issues/detail?id=3804), but I did not know if anybody would notice my reply there.

Summary:
IWebDriver Driver = new FirefoxDriver(); does not work for Mono, as the DotNetZip library (https://dotnetzip.codeplex.com/) is not platform independent and uses backslashes instead of Path.DirectorySeperator. This results in an exception:

System.ArgumentException: Path is empty
  at System.IO.Directory.CreateDirectory (System.String path) [0x00000] in <filename unknown>:0 
  at Ionic.Zip.ZipEntry.InternalExtract (System.String baseDir, System.IO.Stream outstream, System.String password) [0x00000] in <filename unknown>:0 

Actually, there is already a patch created by user moonverma, which should fix this issue (https://www.codeplex.com/Download?ProjectName=dotnetzip&DownloadId=905384). Unfortunately, it does not seem that there will be any new release soon (last update: 2011, and a bunch of open patches and issues).

To make a long story short, have you ever thought of providing a patched version of DotNetZip to enable FirefoxDriver in Mono?

Responsive Design Bug?

I am trying to screen capture a web page (www.constructionequipment.com) using PhantomJSDriver, which works fine locally on my development box but when ran from a web server (without a display) does not properly handle detection of the screen due to the responsive nature of the web page.

What I am seeing happen (on the server) is the horizontal navigation bar at the top of the page always appears to display in a mobile mode (for responsive design) when screen captured, this is regardless of any width that I force the browser window to.

What I am seeing happen (on my development box) is the responsive menu adjusts appropriately as I resize the window programmatically. No issue here.

I was looking at the CSS for www.constructionequipment.com and found a media query being used ("@media" screen) which provides conditional logic for which CSS block to use based on the screen size.

I am thinking that the PhantomJS Driver is (in the case of running on the server) not properly detecting the screen width (since there is no display).

It should be noted that other responsive websites like CNN.com for example, work fine.

Has anyone else encountered this issue?

Thanks in advance.


Below is an attached screen capture of a dropdown menu in a wide browser window (which should be using a navigation bar instead). This was captured by my application running in a server environment and illustrates the problem I am seeing. My application works fine when ran locally.

You can go to constructionequipment.com and horizontally resize the window to see how it should behave.

wide with mobile menu


Custom .NET/C# application using...

Selenium WebDriver API .NET Bindings
Runtime Version v4.0.30319
Version 2.44.0.0

phantomjs.exe

Development machine: Windows 7

Server machine: Win Server 2008 R2

.NET version v4.0.30319


Information about CSS @media queries
http://stackoverflow.com/questions/4189868/what-does-media-screen-and-max-width-1024px-mean-in-css

Initial Page Loading (IE/Chrome) takes huge time if launching via Selenium

Hi Folks,
I am trying to open one of my heavy web application using selenium, and facing considerable performance issue.
when i am opening the same application without selenium it works very very fast, not sure why such issue, (please note i am new to this community, i might be missing something here)

I am also forcing browser to cache the contents, but looking into fiddler contents are also not getting cached.. have spent now a complete day with no satisfaction.. please help

PS : Do we have any active community forum where we get answers from active users.

static NewInternetExplorerDriver driver; 

    @BeforeClass
    public static void launchDriver(){
        System.setProperty("webdriver.ie.driver","IEDriverServer32.exe");
        //System.setProperty("webdriver.chrome.driver", "chromedriver32.exe");

        DesiredCapabilities cap = DesiredCapabilities.internetExplorer();  
        cap.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, false);
        cap.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, false);
        cap.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true);


        Capabilities cap1 = (Capabilities) cap; 

        driver = new NewInternetExplorerDriver(cap1);
        //driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);


    }

    @Test
    public void Step1_LaunchApplication() throws InterruptedException {
        driver.get("http://server23:8086/home");
        System.out.println("Loading Completed"); 
        Thread.sleep(2000); 
    }

Need Serializable InternetExplorerDriver

Hi Folks,
Was Searching google for long hrs to find solution to resume Driver object but didn't find a concrete solution, so that I thought it would be a good idea to Serialize Driver instance and load it again when we rerun.
I am trying to achieve this to expedite automation development process, everytime I rerun the test while development I have to close the browser and re launch it again and again this is very annoying.

So thought that below code would help me, but it is throwing exception that InternetExplorerDriver is not implementing Serializable.

Can someone please help me to fork this class and make it Serializable.

class WebDriverExtention {
    public static WebDriver getDriverObject(){
        WebDriver driver; 

        File f = new File("c:\\tmp\\driver.ser");
        if (!f.exists()){
            System.setProperty("webdriver.ie.driver","IEDriverServer32.exe");
            driver = new InternetExplorerDriver();
            FileOutputStream fout = new FileOutputStream("c:\\tmp\\driver.ser");
            ObjectOutputStream oos = new ObjectOutputStream(fout);
            oos.writeObject(driver);
            oos.close();
            return driver; 
        }
        else{
            f = null; 
            FileInputStream fileIn = new FileInputStream("c:\\tmp\\driver.ser");
            ObjectInputStream ins = new ObjectInputStream(fileIn);
            driver = (WebDriver) ins.readObject();
            ins.close();
            fileIn.close();
            return driver; 
        }

    }
}

UnreachableBrowserException in Selenium 2.45 when used in combination with SoapUI

Used versions:
SoapUI Pro v 5.1.2 (soapui-pro-maven-plugin)
Selenium 2.45 is used (selenium-java)
httpclient 4.3.6 is used

Steps to reproduce:
WsdlProject wsdlProject = new WsdlProject("");
WebDriver driver = new FirefoxDriver();

Result in Selenium 2.45:
The Browser is started but closed immediately.
Reproducible in Firefox and Chrome.

The following exception is thrown:

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.45.0', revision: '5017cb8e7ca8e37638dc3091b2440b90a1d8686f', time: '2015-02-27 09:10:26'
System info: host: 'xxx', ip: 'XXX.XXX.XXX.XXX', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_75'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:191)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:182)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:95)
at my.project.selenium.webdriver.test.foo(awda.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:696)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:882)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1189)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:125)

Result in Selenium 2.44:
Works as expected

I was able to trace the problem down to ApacheHttpClient, line 72:
org.apache.http.HttpResponse response = fallBackExecute(context, httpMethod);
The Problem seems to be the communication between selenium and the webdriver.

From the release notes of v 2.45: "Pull HttpClient implementation details out of HttpCommandExecutor".Maybe this change is responsible for the behavior?

unable to use actual iOS device

Hello as mentioned in the tutorial i cloned the git repo, however on doing the ./go iPhone ; i am unable to get the device. I made sure the device is in the network and is connected. is there a detailed tutorial for using actual physical devices?? if yes please share it with me screenshots will also be helpful . thanks in advance

Unable to pass chrome options into remote webdriver

Python 2.7 (Selenium 2.45 package)
Ubuntu 14.04 Selenium Grid 2.45

I am currently running into an issue where I am unable to pass chrome options to the grid correctly. It appears to be due to a java casting error. It matches correctly but then cannot cast chrome options, even if left as an empty string. Other capabilities work fine though, and it works correctly if I remove chrome options.

Hub stacktrace:

12:47:46.784 INFO - Got a request to create a new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, chromeOptions={args=[--use-fake-device-for-media-stream, --disable-user-media-security=true], extensions=[]}, version=}]
12:47:46.784 INFO - Available nodes: [host :http://172.17.42.1:5555]
12:47:46.784 INFO - Trying to create a new session on node host :http://172.17.42.1:5555
12:47:46.784 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, platform=LINUX, chrome_binary=/usr/bin/google-chrome, browserName=chrome, maxInstances=8, version=41}
12:47:46.785 ERROR - Error running the beforeSessionListener : java.util.HashMap cannot be cast to com.google.gson.JsonObject
java.lang.ClassCastException: java.util.HashMap cannot be cast to com.google.gson.JsonObject
    at org.openqa.grid.selenium.proxy.DefaultRemoteProxy.beforeSession(DefaultRemoteProxy.java:238)
    at org.openqa.grid.web.servlet.handler.RequestHandler.beforeSessionEvent(RequestHandler.java:169)
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:110)
    at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
    at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
    at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
    at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
    at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
    at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
    at java.lang.Thread.run(Thread.java:745)

Python Stacktrace:

WebDriverException: Message: Error forwarding the new session The listener threw an exception ( listener bug )
Stacktrace:
    at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:114)
    at org.openqa.grid.web.servlet.DriverServlet.process (DriverServlet.java:83)
    at org.openqa.grid.web.servlet.DriverServlet.doPost (DriverServlet.java:67)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:820)
    at org.seleniumhq.jetty7.servlet.ServletHolder.handle (ServletHolder.java:565)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle (ServletHandler.java:479)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle (SessionHandler.java:225)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle (ContextHandler.java:1031)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doScope (ServletHandler.java:406)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doScope (SessionHandler.java:186)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope (ContextHandler.java:965)
    at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle (ScopedHandler.java:117)
    at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle (HandlerWrapper.java:111)
    at org.seleniumhq.jetty7.server.Server.handle (Server.java:349)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest (AbstractHttpConnection.java:452)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest (BlockingHttpConnection.java:47)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.content (AbstractHttpConnection.java:894)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content (AbstractHttpConnection.java:948)
    at org.seleniumhq.jetty7.http.HttpParser.parseNext (HttpParser.java:857)
    at org.seleniumhq.jetty7.http.HttpParser.parseAvailable (HttpParser.java:235)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle (BlockingHttpConnection.java:66)
    at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run (SocketConnector.java:254)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:599)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:534)
    at java.lang.Thread.run (Thread.java:745)

WebDriver class does not accept a session_id

Allowing a session_id to be set on the WebDriver would allow reuse of an existing session.
Tested working.

selenium/webdriver/remote/webdriver.py - class WebDriver

doc says:
" - session_id - The session ID to send with every command."

Added session_id=None to init
...
self.session_id = None changed to self.session_id = session_id
...
Changed to quash new session if a session id is specified
if session_id is None: # Do not start a new session if there is already a session id
self.start_session(desired_capabilities, browser_profile)

Focused input not allowing multiple delete / backspace keypresses

What steps will reproduce the problem?

Create a fixture html file called "focustest.html" with the following content:

<!DOCTYPE html>
<html>
<head>
    <title>Focus Test</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
    <input id="field" name="data" value="Initial Value" type="text" />

    <button id="focusbtn" onclick="doFocus()">Focus</button>

    <script>
      function doFocus() {
        document.getElementById('field').focus();
      }
    </script>
</body>
</html>

Create a PHPUnit test called "test.php" with the following content:

class WebTest extends PHPUnit_Extensions_Selenium2TestCase {

  function setUp() {
    $this->setBrowser('firefox');
    $this->setBrowserUrl('http://localhost/');
  }

  function testFillFocusedField() {
    $value = 'Chekote';

    $this->url('/focustest.html');
    $this->byId('focusbtn')->click();

    // get the field value current length, and add backspace/delete keystrokes to remove it
    $field = $this->byId('field');
    $deletes = str_repeat(
      PHPUnit_Extensions_Selenium2TestCase_Keys::BACKSPACE . PHPUnit_Extensions_Selenium2TestCase_Keys::DELETE,
      strlen($field->value())
    );

    $this->keys($deletes . $value);

    $this->assertEquals($value, $field->value());
  }
}

Run the test:

phpunit test.php

What is the expected output?
I expect the test to pass, and the field's "Initial Value" text to be replaced with "Chekote"

What do you see instead?
The first character of the Initial Value (The "I") is deleted, but no other characters are deleted. The result is the field have the value "Chekotenitial Value".

Selenium version: 2.45
OS: Mac OS X 10.10.2
Browser: Firefox
Browser version: 31.4.0esr, 33.1.1, 34.0.5 & 36.0.1

This problem was first discovered and discussed in the MinkSelenium2Driver issues board here:

minkphp/MinkSelenium2Driver#198

It was also originally reported here. I closed it thinking a typo was causing the tests to fail, but the typo was not the only reason it was failing. Sorry for the confusion!

https://code.google.com/p/selenium/issues/detail?id=8589

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.