Skip to content
NickAb edited this page Oct 28, 2014 · 2 revisions

Strategies

v 0.1.5414.25590 or higher

id

Use this when you know AutomationProperties.AutomationId attribute of an element.

driver.find_element_by_id('SearchBar')

name

Use this when you know AutomationProperties.Name attribute of an element.

driver.find_element_by_name('AddressLabel')

Before 0.1.5414.25590 name strategy used Name property, not AutomationProperties.Name


tag name

class name

Use this when you want to locate an element by its class name (complete with namespace).

driver.find_element_by_tag_name('System.Windows.Controls.TextBlock')

xname

Transitional. To be depricated. Use this when you want to locate an element by its Name property (NOT AutomationProperties.Name). Not recomended. Add AutomationProperties.Name to the element you are planning to use in test and use name strategy instead.

from selenium.webdriver.common.by import By

By.XNAME = 'xname'  # enable xname as valid By strategy
...

driver.find_elements('xname', 'Title')
Clone this wiki locally