- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What to press ctrl +c on a page in Selenium with python?
We can perform the action of pressing ctrl+c keys in Selenium. There are multiple special Keys available that enable the act of pressing keys via a keyboard like ctrl+c, ctrl+v, ctrl+f and many more. These special Keys are a part of selenium.webdriver.common.keys.Keys class.
key_down() – This method performs the action sending a key press only and not releasing it. The key_down() method is a part of Action Chains class. This method is widely used for coping and pasting actions via (ctrl+c, ctrl+v).
In order to carry out this action, we need to first press the ctrl key downwards and simultaneously press C key. These two steps can be automated by key_down() method and can only be used along with Shift, Alt and Control keys.
Syntax
key_down(args1, args2)
Here args1 is the key to be sent. The key is defined in Keys class.
The args2 parameter is the element to send keys. If omitted, it shall send a key to the element which is presently in focus.
Example
Code Implementation to press ctrl+c.
from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.common.keys import Keys #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/about/about_careers.htm") #to refresh the browser driver.refresh() # action chain object creation a = ActionChains(driver) # perform the ctrl+c pressing action a.key_down(Keys.CONTROL).send_keys('C').key_up(Keys.CONTROL).perfo rm() #to close the browser driver.close()
- Related Articles
- What to press ctrl +f on a page in Selenium with python?
- Key press in (Ctrl+A) Selenium WebDriver.
- Save a Web Page with Python Selenium
- How to check a checkbox in a page in Selenium with python?
- Finding text on page with Selenium 2
- How to select a radio button in a page in Selenium with python?
- How to get the complete screenshot of a page in Selenium with python?
- How to count the number of checkboxes in a page in Selenium with python?
- Take screenshot of full page with Selenium Python with chromedriver.
- What are the methods available for handling static dropdowns in a page in Selenium with python?
- How to perform scrolling action on page in Selenium?
- How to refresh a browser then navigate to a new page with Javascript executor in Selenium with python?
- How to find the status of an element in a page in Selenium with python?
- How to count the total number of tables in a page in Selenium with python?
- How to click on a link in Selenium with python?
