[PYTHON] I really wanted to copy with selenium

I want to copy sentences with selenium webdriver!

But selenium didn't have a copy command! (Maybe I just overlooked it)

I thought I should do ctrl + C with sendkeys, but I can't

Then I'll do it like this! !!

Environment: ubuntu12.04, python2.7, selenium, chrome

python


copy = driver.execute_script("return window.getSelection().toString();")

Extract the characters in the selection with execute_script and assign them to variables

I ran javascript from selenium and was able to copy it! !!

By the way, all selections are like this

python


driver.execute_script("document.execCommand('SelectAll');")

Recommended Posts

I really wanted to copy with selenium
I wanted to solve ABC160 with Python
I wanted to solve ABC172 with Python
I wanted to solve NOMURA Contest 2020 with Python
I wanted to play with the Bezier curve
I also wanted to check type hints with numpy
I was addicted to scraping with Selenium (+ Python) in 2020
I wanted to solve the Panasonic Programming Contest 2020 with Python
Challenge problem 5 with Python: lambda ... I decided to copy without
I want to automatically attend online classes with Python + Selenium!
I captured the Touhou Project with Deep Learning ... I wanted to.
I wanted to calculate an array with Sympy's subs method
I wanted to delete multiple objects in s3 with boto3
Hash chain I wanted to avoid (2)
I wanted to evolve cGAN to ACGAN
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
Hash chain I wanted to avoid (1)
A memorandum when I tried to get it automatically with selenium
I wanted to create a smart presentation with Jupyter Notebook + nbpresent
I tried to make a periodical process with Selenium and Python
I wanted to solve the ABC164 A ~ D problem with Python
I really want to use GitHub Flavored Markdown (GFM) with Pelican!
I tried to log in to twitter automatically with selenium (RPA, scraping)
I want to detect objects with OpenCV
I tried to implement Autoencoder with TensorFlow
I tried to visualize AutoEncoder with TensorFlow
I tried to get started with Hy
I want to blog with Jupyter Notebook
I tried using Selenium with Headless chrome
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I want to play with aws with python
[Introduction to Pytorch] I played with sinGAN ♬
I wanted to solve ABC159 in Python
I tried to implement CVAE with PyTorch
copy consumer offset to another with kafka-python
I tried to solve TSP with QAOA
Implemented DQN in TensorFlow (I wanted to ...)
I wanted to use jupyter notebook with docker in pip environment (opticspy)
I made a tool to automatically browse multiple sites with Selenium (Python)
I tried to predict next year with AI
I tried to make a periodical process with CentOS7, Selenium, Python and Chrome
Scraping with selenium
I tried to detect Mario with pytorch + yolov3
I tried to implement reading Dataset with PyTorch
Scraping with selenium ~ 2 ~
I want to use MATLAB feval with python
I tried to learn logical operations with TF Learn
I tried to move GAN (mnist) with keras
i-Town Page Scraping: I Wanted To Replace Wise-kun
I tried to save the data with discord
I tried to detect motion quickly with OpenCV
I tried to integrate with Keras in TFv1.1
I want to mock datetime.datetime.now () even with pytest!
I want to display multiple images with matplotlib.
I want to knock 100 data sciences with Colaboratory
I want to make a game with Python
I want to be an OREMO with setParam!
I tried to get CloudWatch data with Python