[PYTHON] I want to move selenium for the time being [for mac]

Introduction

A web browser test tool called selenium, Roughly speaking, I knew that there was something that could automatically operate the web screen by writing a little code. I wanted to try it for the time being.

I borrowed a lot of wisdom from my ancestors, but I made a note because there were some stumbling points.

It will be similar to sutra copying, but the basics are Introduction to Selenium starting with just 3 lines of python Keep a record of where you stumbled along. (As of September 10, 2020)

What you can do

On the browser screen using selenium Automatically display search results for the character string "raccoon dog image"

environment

Advance preparation

procedure

$ brew install chromedriver

#I couldn't install it above, so I tried this as the error statement says.
$ brew cask install chromedriver
$ pip install selenium

test.py


from selenium import webdriver

driver = webdriver.Chrome("chromedriver path") 

driver.get("https://google.co.jp")

The chromedriver path can be found with which chromedriver

$ python test.py

I got an error in the pop-up here, so I gave permission to execute the downloaded application by referring to the following.

When I tried to use selenium, I was told that "" chromedriver "cannot be opened because the developer cannot be verified."

This should open your chrome web browser.

If you can do it so far, write the following

test.py


from selenium import webdriver 
from selenium.webdriver.common.keys import Keys #add to

driver = webdriver.Chrome("/usr/local/bin/chromedriver")
driver.get("https://google.co.jp")

text = driver.find_element_by_name("q") #Specify the name attribute of the search box
text.send_keys("Raccoon image")#String"Raccoon image"In the text box
text.send_keys(Keys.ENTER) #Press ENTER Use a special key

Stumbling point

→ I decided to specify the name attribute

→ I set it to press ENTER (instead of searching for and clicking the search button) [^ 1]

error contents

 :
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

Summary

I couldn't investigate why such an error occurred, but For the time being, the web browser opens automatically and characters are entered in the search box without permission. I was able to reach the point where the search results are displayed.

[^ 1]: From selenium quick reference

Recommended Posts

I want to move selenium for the time being [for mac]
I want to create a Dockerfile for the time being.
For the time being, I want to convert files with ffmpeg !!
Flow memo to move LOCUST for the time being
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
I played with Floydhub for the time being
I tried Python on Mac for the first time.
Molecular dynamics simulation to try for the time being
I will install Arch Linux for the time being.
Next to Excel, for the time being, jupyter notebook
[Hi Py (Part 1)] I want to make something for the time being, so first set a goal.
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
For the time being using FastAPI, I want to display how to use API like that on swagger
[TensorFlow] I want to master the indexing for Ragged Tensor
I tried running PIFuHD on Windows for the time being
I want to create a lunch database [EP1] Django study for the first time
I want to create a lunch database [EP1-4] Django study for the first time
[Introduction to Reinforcement Learning] Reinforcement learning to try moving for the time being
I tried to move the ball
I want to get the name of the function / method being executed
I want to record the execution time and keep a log.
Java programmer tried to touch Go language (for the time being)
Understanding the python class Struggle (1) Let's move it for the time being
Challenge image classification by TensorFlow2 + Keras 1-Move for the time being-
I want to pin Spyder to the taskbar
I want to output to the console coolly
I tried tensorflow for the first time
I want to handle the rhyme part1
Python Master RTA for the time being
I want to handle the rhyme part3
I want to use Linux on mac
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
"Stop committing Japanese files to git on Mac> <" For the time being, I wrote a script to search for incompatible Japanese files on Mac and Linux.
I made a function to check if the webhook is received in Lambda for the time being
Challenge image classification with TensorFlow2 + Keras CNN 1 ~ Move for the time being ~
I want to separate the processing between test time and production environment
(Python Selenium) I want to check the settings of the download destination of WebDriver
For the first time in Numpy, I will update it from time to time
Python: I want to measure the processing time of a function neatly
I tried using scrapy for the first time
How to use MkDocs for the first time
For the time being, import them into jupyter
Make a histogram for the time being (matplotlib)
Use logger with Python for the time being
Run yolov4 "for the time being" on windows
I want to handle the rhyme part7 (BOW)
I tried python programming for the first time.
Try using LINE Notify for the time being
I want to manage systemd by time zone! !!
I tried Mind Meld for the first time
I want to customize the appearance of zabbix
virtualenv For the time being, this is all!
I want to use the activation function Mish
I want to display the progress in Python!
Try posting to Qiita for the first time
I want to create a nice Python development environment for my new Mac
Try adding an external module to pepper. For the time being, in requests.