1
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.chrome("C:\\Users\Ivan\Documents\Python\chromedriver_win32")
driver.get("https://www.google.com")
assert "google" in driver.title

Python rookie here, i dont get why am i getting 'module' object is not callable, some help will be appreciated thanks!

ihincapie
  • 65
  • 1
  • 6

1 Answers1

2

You made a typo. webdriver.chrome doesn't exist. You'll need to use webdriver.Chrome Note the capital C).

Your code, with this correction, will function perfectly fine. Note, however, that assertions are also case-sensitive. The title of the website https://google.com is Google and not google. By changing the final line of the script to assert "Google" in driver.title you will find that it'll run without errors.

ChromeDriver also has its own reference documentation, which provides several examples of how to use ChromeDriver with Python and Selenium.

The code below should work fine, though I recommend adding ChromeDriver to your PATH variables. This will allow you to simply call webdriver.Chrome() rather than having to specify its location.

import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome("C:\\Users\Ivan\Documents\Python\chromedriver_win32")
driver.get("https://www.google.com")
assert "google" in driver.title
Glazbee
  • 640
  • 5
  • 22