Skip to content
This repository was archived by the owner on Jul 2, 2020. It is now read-only.

pySelenium tricks

Timotheus Pokorra edited this page Jun 8, 2015 · 2 revisions

Wait for an element to be clickable

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0

btnSave = wait.until(EC.element_to_be_clickable((By.XPATH, "//form[@id=\"password-form\"]//input[@class=\"button mainaction\"]")),
              "timeout: cannot change password");
btnSave.click()

show the HTML code of an element

print(elem.get_attribute('innerHTML'));

Clone this wiki locally