Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
937 views
by The go-to Tester (218 points)
I am running the following Webdriver test in python

from selenium import webdriver
import os
from selenium.webdriver.common.keys import Keys
# create a new Firefox session
chromedriver = "C:\Selenium driver\chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver)
driver.implicitly_wait(30)
driver.maximize_window()
# navigate to the application home page
driver.get("http://www.google.com")
# get the search textbox
search_field = driver.find_element_by_id("lst-ib")
search_field.clear()
# enter search keyword and submit
search_field.send_keys("Nutrilite products")
search_field.submit()
# get the list of elements which are displayed after the search
# currently on result page using find_elements_by_class_name  method
lists= driver.find_elements_by_class_name("_Rm")
# get the number of elements found
print ('Found ' + str(len(lists)) + 'searches:')
# iterate through each element and print the text that is
# name of the search
i=0
for listitem in lists:
    print (listitem)
    i=i+1
    if(i>10):
        break
# close the browser window
driver.quit()

I am getting following error-:

Traceback (most recent call last):
  File "E:\Python Workspace\GoogleSearch.py", line 1, in <module>
    from selenium import webdriver
ImportError: cannot import name webdriver

Please help

1 Answer

0 like 0 dislike
by

Have you done from 

pip install selenium

the command line?

It looks like selenium is not installed.

by The go-to Tester (218 points)
Selenium is already installed. It says Requirement already satisfied.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...