0% found this document useful (0 votes)
8 views1 page

Selenium Python Cheat Sheet Color

This document is a cheat sheet for using Selenium with Python, covering installation, importing, driver initialization, setting options, locators, actions, waits, taking screenshots, and teardown. It provides code snippets for each section to assist users in implementing Selenium functionalities. The cheat sheet serves as a quick reference guide for developers working with Selenium in Python.

Uploaded by

hello.softworica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Selenium Python Cheat Sheet Color

This document is a cheat sheet for using Selenium with Python, covering installation, importing, driver initialization, setting options, locators, actions, waits, taking screenshots, and teardown. It provides code snippets for each section to assist users in implementing Selenium functionalities. The cheat sheet serves as a quick reference guide for developers working with Selenium in Python.

Uploaded by

hello.softworica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Selenium Python Cheat Sheet

1. Installation
pip install selenium

2. Importing
from selenium import webdriver

3. Driver Initialization
driver = webdriver.Chrome()
driver = webdriver.Firefox()

4. Setting Options
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--disable-extensions')
driver = webdriver.Chrome(options=chrome_options)

5. Locators
driver.find_element_by_id('id') # By ID
driver.find_element_by_name('name') # By Name
driver.find_element_by_class_name('class') # By Class
driver.find_element_by_xpath('//tag[@attr]') # By XPath
driver.find_element_by_css_selector('css') # By CSS Selector

6. Actions
element.click()
element.send_keys('text')

7. Waits
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'id')))

8. Screenshots
driver.save_screenshot('screen.png')

9. Teardown
driver.quit()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy