?
Solved

Python Selenium Webdriver Login Issues On Mac

Posted on 2016-08-19
5
Medium Priority
?
208 Views
Last Modified: 2016-11-15
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

0
Comment
Question by:sharingsunshine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 16

Expert Comment

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

Open in new window

0
 

Author Comment

by:sharingsunshine
ID: 41763622
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

0
 
LVL 16

Accepted Solution

by:
Walter Ritzel earned 2000 total points
ID: 41763824
Add this line on your import section:
from selenium.webdriver.common.by import By

Open in new window

0
 

Author Comment

by:sharingsunshine
ID: 41763877
that was right on.  As always, great help you give.
0
 

Expert Comment

by:Ranadheer Kurakula
ID: 41887721
You can actually use  
driver.find_element_by_link_text('SIGN IN').click()

Open in new window

This will work fine.
1

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question