Avatar of sharingsunshine
sharingsunshine
Flag for United States of America asked on

Python Selenium Webdriver Login Issues On Mac

I had this question after viewing Using Python To Iterate Through All Website Pages And Paste Changed Content Back.

I am able to open https://www.blogger.com/about/ but then I need to click on the SIGN IN link at the top right of the screen and then insert my username and password but keep getting strange errors.  I am using Python 3.3.6 and Selenium 2.53.6

I am getting this error in my code
File "expertsBrazil2webdriver.py", line 16, in <module>
    driver.findElement (By.linkText("SIGN IN")).click()
AttributeError: 'WebDriver' object has no attribute 'findElement'

Open in new window


Here is the code I am using
from selenium import webdriver
from selenium.webdriver.common.proxy import *
import traceback
import random
import os
import time

os.environ["SELENIUM_SERVER_JAR"] = "/Users/rjw/Documents/Python/selenium-server-standalone-3$

browser = None
try:
  # browser = webdriver.Firefox()
    driver = webdriver.Safari()
    driver.get('https://www.blogger.com/about/')   # navigate to your blog
    time.sleep(5)
    driver.findElement (By.linkText("SIGN IN")).click()
except:
    print(traceback.format_exc())
finally:
    if browser:
        browser.quit()

Open in new window

PythonMac OS X

Avatar of undefined
Last Comment
Ranadheer Kurakula

8/22/2022 - Mon
Walter Ritzel

The correct method is find_element not findElement.
Example from Selenium Documentation:
cheese = driver.find_element(By.LINK_TEXT, "cheese")

Open in new window

sharingsunshine

ASKER
I am getting this error  

 File "expertsBrazil2webdriver.py", line 16, in <module>
    SIGN_IN = driver.find_element(By.LINK_TEXT, "SIGN IN")
NameError: name 'By' is not defined

Open in new window

ASKER CERTIFIED SOLUTION
Walter Ritzel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sharingsunshine

ASKER
that was right on.  As always, great help you give.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Ranadheer Kurakula

You can actually use  
driver.find_element_by_link_text('SIGN IN').click()

Open in new window

This will work fine.