Questions tagged [webdriver]

WebDriver is an API for controlling web browsers, imitating a real user. It's mostly used for automated tests. WebDriver has multiple language bindings and drivers (allowing to control various browsers). If your question is specific to one of them, make sure to also include the appropriate tag.

WebDriver is an API that allows programs or scripts to introspect into, and control the behavior of, a web browser. It is primarily intended for allowing tests that automate a browser.

The WebDriver API is implemented, natively or via add-ons, for many browsers. The Selenium tools suite provides several WebDriver implementations, e.g. for Firefox or Internet Explorer. Other WebDriver implementations are developed by the browser projects directly, e.g. ChromeDriver for Chrome, or Ghost Driver for PhantomJS.

The WebDriver API specifies a wire protocol which is used for the communication between a WebDriver client and the browser. Clients do not speak the wire protocol directly, they use "language bindings" of the WebDriver API for the respective programming language. The wire protocol is used by the Selenium Grid to pass API commands across network.

There are language bindings of the WebDriver API for Java, C#, Python, Ruby, Perl, PHP, JavaScript, and other languages. Many of the language bindings are provided by the Selenium project. For some languages, there are even multiple language bindings, e.g. WebDriverJs by Selenium and WebdriverJS by webdriver.io.


Reference Links

12238 questions
90
votes
9 answers

How to check if an alert exists using WebDriver?

I need to check the existence of Alert in WebDriver. Sometimes it pops up an alert but sometimes it will not pop up. I need to check if the alert exists first, then I can accept or dismiss it or it will say: no alert found.
Yunfei Gu
  • 921
  • 1
  • 6
  • 3
88
votes
4 answers

find_element_by_* commands are deprecated in Selenium

When starting the function def run(driver_path): driver = webdriver.Chrome(executable_path=driver_path) driver.get('https://tproger.ru/quiz/real-programmer/') button = driver.find_element_by_class_name("quiz_button") …
Alexandr
  • 999
  • 1
  • 4
  • 7
88
votes
22 answers

ImportError: No module named 'selenium'

I'm trying to write a script to check a website. It's the first time I'm using selenium. I'm trying to run the script on a OSX system. Although I checked in /Library/Python/2.7/site-packages and selenium-2.46.0-py2.7.egg is present, when I run the…
Giulio Colleluori
  • 1,261
  • 2
  • 10
  • 16
86
votes
13 answers

How to check if an element is visible with WebDriver

With WebDriver from Selenium 2.0a2 I am having trouble checking if an element is visible. WebDriver.findElement returns a WebElement, which unfortunately doesn't offer an isVisible method. I can go around this by using WebElement.clear or…
ponzao
  • 20,684
  • 3
  • 41
  • 58
85
votes
4 answers

WebDriver - wait for element using Java

I'm looking for something similar to waitForElementPresent to check whether element is displayed before I click it. I thought this can be done by implicitWait, so I used the following: driver.manage().timeouts().implicitlyWait(5,…
tom
  • 1,223
  • 6
  • 16
  • 26
84
votes
15 answers

Difference between webdriver.get() and webdriver.navigate()

What is the difference between get() and navigate() methods? Does any of this or maybe another method waits for page content to load? What do I really need is something like Selenium 1.0's WaitForPageToLoad but for using via webdriver. Any…
Invy
  • 1,058
  • 1
  • 10
  • 12
84
votes
7 answers

Finding elements by class name with Selenium in Python

How can I filter elements that have the same class?

Link1.

Link2.

Sree
  • 849
  • 1
  • 6
  • 3
84
votes
12 answers

setting request headers in selenium

I'm attempting to set the request header 'Referer' to spoof a request coming from another site. We need the ability test that a specific referrer is used, which returns a specific form to the user, otherwise an alternative form is given. I can do…
tamouse
  • 2,169
  • 1
  • 19
  • 26
82
votes
5 answers

How to switch to new window in Selenium for Python?

I am working on selenium automation project using Python. I am facing an issue, which is handling multiple browser windows. Scenario is as follows. When I click a link on the home page, a new window opens. In the newly opened window I cannot perform…
Sandeep Raveendran
  • 821
  • 1
  • 7
  • 3
79
votes
22 answers

Open web in new tab Selenium + Python

So I am trying to open websites on new tabs inside my WebDriver. I want to do this, because opening a new WebDriver for each website takes about 3.5secs using PhantomJS, I want more speed... I'm using a multiprocess python script, and I want to get…
Robert W. Hunter
  • 2,895
  • 7
  • 35
  • 73
78
votes
5 answers

How can I get the current contents of an element in webdriver

I must be thinking about this wrong. I want to get the contents of an element, in this case a formfield, on a page that I am accessing with Webdriver/Selenium 2 Here is my broken code: Element=driver.find_element_by_id(ElementID) print Element …
Skip Huffman
  • 5,239
  • 11
  • 41
  • 51
70
votes
14 answers

Webdriver Screenshot

When taking a screenshot using Selenium Webdriver on windows with python, the screenshot is saved directly to the path of the program, is there a way to save the .png file to a specific directory?
user1152578
  • 785
  • 1
  • 7
  • 8
70
votes
18 answers

How do you fix the "element not interactable" exception?

I know this has been asked lots of times before but how do you get around the "element not interactable" exception? Here is my code: button =…
Rolodophone
  • 813
  • 1
  • 7
  • 10
64
votes
7 answers

How do I set proxy for chrome in python webdriver?

I'm using this code: profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 1) profile.set_preference("network.proxy.http", "proxy.server.address") profile.set_preference("network.proxy.http_port",…
sarbo
  • 1,661
  • 6
  • 21
  • 26
63
votes
13 answers

How to fix Selenium WebDriverException: The browser appears to have exited before we could connect?

I have installed firefox and Xvfb on my centos6.4 server to use selenium webdriver. But, when I run the code, I got an error. from selenium import webdriver browser = webdriver.Firefox() Error selenium.common.exceptions.WebDriverException: Message:…
W3Q
  • 909
  • 1
  • 11
  • 19