Challenge Python3 and Selenium Webdriver

Trigger

Since the test work to be done at work is long and time-consuming, I also tried to study Python3

usage environment

system-name Target version / environment
OS macOS sierra 10.12.5
browser Chrome 59.0.3071.115
Python 3.6.1
Selenium 3.4.3
virtualenv 15.1.0
ChromeDriver 2.30

procedure

Basically, I referred to Official Document

  1. Prepare a place to create an environment with virtualenv

    $ cd Desktop  
    $ mkdir PythonEnv
    $ cd PythonEnv
    
  2. Create a virtual environment

    $ virtualenv SeleniumPython
    $ cd SeleniumPython
    
  3. Install selenium with pip

    $ pip install selenium
    Collecting selenium
      Downloading selenium-3.4.3-py2.py3-none-any.whl (931kB)
        100% |████████████████████████████████| 942kB 622kB/s 
    Installing collected packages: selenium
    Successfully installed selenium-3.4.3
    
  4. Download ChromeDriver from ChromeDriver --WebDriver for Chrome

  5. Place the unzipped files under the / usr / local / bin folder (anything that is in the path looks good)

    $ sudo mv chromedriver /usr/local/bin
    
  6. Enter the created virtual environment

    $ pwd
    /Users/<User name>/Desktop/SeleniumPython
    $ source bin/activate
    
  7. Create the following Python file

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    driver = webdriver.Chrome()
    driver.get("http://www.python.org")
    assert "Python" in driver.title
    elem = driver.find_element_by_name("q")
    elem.clear()
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source
    driver.close()
    

Execute the created Python file

$ python python_org_search.py

Then Chrome will start automatically and the official Python page will be launched.

from now on

For the time being, I'm going to try Official Document 2. Getting Started.

Recommended Posts

Challenge Python3 and Selenium Webdriver
Selenium WebDriver + Firefox49 (provisional) (Python)
Scraping with Python, Selenium and Chromedriver
Selenium and python to open google
[Python / Selenium] XPath
[Python] Challenge 100 knocks! (015 ~ 019)
[Python] Challenge 100 knocks! (030-034)
phantomjs and selenium
[Python] Challenge 100 knocks! (010-014)
[Python] Challenge 100 knocks! (025-029)
Practice web scraping with Python and Selenium
My Webdriver (Python)
Use selenium phantomjs webdriver with python unittest
python challenge diary ①
[Python] Challenge 100 knocks! (020-024)
Selenium + WebDriver (Chrome) + Python | Building environment for scraping
I tried web scraping using python and selenium
Try running Google Chrome with Python and Selenium
Drag and drop local files with Selenium (Python)
[python] Compress and decompress
Python and numpy tips
[Python] pip and wheel
Python iterators and generators
Python packages and modules
Vue-Cli and Python integration
Ruby, Python and map
python input and output
Python and Ruby split
ScreenShot with Selenium (Python)
Python asyncio and ContextVar
python selenium chromedriver beautifulsoup
Use FireFox (via Homebrew-cask) with Selenium WebDriver Python bindings
Install selenium on Mac and try it with python
Automated testing method combining Beautiful Soup and Selenium (Python)
Automatically translate DeepL into English with Python and Selenium
Programming with Python and Tkinter
Encryption and decryption with Python
Python: Class and instance variables
3-3, Python strings and character codes
Python 2 series and 3 series (Anaconda edition)
Scraping with selenium in Python
Python and hardware-Using RS232C with Python-
Scraping with Selenium + Python Part 1
Python on Ruby and angry Ruby on Python
Python indentation and string format
Install Python and Flask (Windows 10)
About python objects and classes
About Python variables and objects
[Python] Eliminate Chrome Webdriver errors
Apache mod_auth_tkt and Python AuthTkt
Å (Ongustromu) and NFC @ Python
Understand Python packages and modules
# 2 [python3] Separation and comment out
Python: Working with Firefox with selenium
Python shallow copy and deep copy
Python Selenium Dynamic download wait
Python and ruby slice memo
Python installation and basic grammar
[Python] Introduction to scraping | Program to open web pages (selenium webdriver)
I compared Java and Python!
Python shallow and deep copy