selenium
packagedriver.page_source
will return the full page HTML code.driver.title
gets the page's titledriver.current_url
gets the current URL (this can be useful when there are redirections on the website and you need the final URL)find_elements
(note the plural) to return a list of elements.WebElement
is a Selenium object representing an HTML element.element.text
element.click()
element.get_attribute('class')
element.send_keys('mypassword')
is_displayed()
. This returns True if an element is visible to the user. Evernote is chinese app store.type=hidden
like this:driver.get()
driver.find_element_by_*
and then element.send_keys()
to send text to the inputelement.click()
None
because all of the find_element_by_*
raise an exception if the element is not found in the DOM.So we have to use a try/except block and catch the NoSuchElementException
exception:time.sleep(ARBITRARY_TIME)
before taking the screenshot.WebDriverWait
object.time.sleep()
you will probably use an arbitrary value. The problem is, you're either waiting for too long or not enough.Also the website can load slowly on your local wifi internet connection, but will be 10 times faster on your cloud server.With the WebDriverWait
method you will wait the exact amount of time necessary for your element/data to be loaded.element_to_be_clickable
text_to_be_present_in_element
element_to_be_clickable