GUI Elements Locators Flashcards

1
Q

find_element_ (return a single WebElement) or find_elements_ (return a list of WebElements) methods:

A
by_id (id_)
by_class_name (name)
by_tag_name (name)
by_xpath (xpath)
by_css_selector (css_selector)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

W3C DOM Definition

A

A platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What it is included in the DOM definition of web elements?

A
  • HTML elements as objects
  • The properties of all HTML elements
  • The methods that can be used to access all HTML elements
  • The events that affect all HTML elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

CODE: Locate by ID

A

element = driver.find_element_by_id(‘the_id’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CODE: Locate by Class

A

element = driver.find_element_by_class_name(‘the_class’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CODE: Locate by Tag

A

element = driver.find_element_by_tag_name(‘h2’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Two methods to identify the WebElement by the link text (an anchor tag which contains text that will be highlighted for a user to click on):

A

element = driver.find_element_by_link_text(‘Click the link’)

element = driver.find_element_by_partial_link_text(‘Click’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

CODE: Using XPath Location

A

element = driver.find_element_by_xpath(‘//form[@id=’sample’]/input[2]’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

CODE: Identifying WebElement via CSS Selector

A

driver.find_element_by_css_selector(‘p.paragraph’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

predefined classes that do not simply determine if an element exists, but also check for a specific state for that element to be in.

A

expected_conditions module from selenium.webdriver.support

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

For test automation, what are the reasons do we have to know more information (its current visibility, whether it is enabled or not, or whether it is selected or not) about the elements in a webpage?

A
  • Ensure the state is as expected at a given point in the test
  • Make sure a control is in a state that it can be manipulated as needed in the test case (i.e., enabled)
  • Make sure that after the control was manipulated, it is now in the expected state
  • Make sure that the expected results are correct after a test is run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

get_attribute()

A

Gets property. If no property by that name, gets attribute of that name. If neither, returns None

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

get_property()

A

Gets property.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

is_displayed()

A

Returns true if visible to user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

is_enabled()

A

returns true if element is enabled

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

is_selected()

A

Returns X,Y location on the renderable canvas

17
Q

size

A

Returns the Height and Width of the element

18
Q

tag_name

A

Returns the tag_name of the element

19
Q

text

A

Returns the text associated with the element

20
Q

CODE: clear input control

A

Element.clear()

21
Q

CODE: Type into an input control

A

Element.send_keys(“this is the typed text”)

22
Q

CODE: wait to ensure that an element it is ready to be clicked

A

Driver.support.expected_conditions.element_to_be_clickable(locator)

23
Q

CODE: Click on WebElement

A

Element.click()

24
Q

Selection options in Select Control:

A
  • Search through the HTML to find the item desired and then click on it
  • Select by an item value (select_by_value(value))
  • Select all items that display matching text (select_by_visible_text(text))
  • Select an item by index (select_by_index(index))
25
Q

Deselection options in Select Control:

A
  • Deselect all items (deselect_all())
  • Deselect by index (deselect_by_index(index))
  • Deselect by value (deselect_by_value(value))
  • Deselect by visible text (deselect_by_visible_text(text))
26
Q

options that allows to see what has been selected in a Select Control:

A
  • Return a list of all selected items (all_selected_options)
  • Return the first selected (or only if a single select control) (first_selected_option)
  • See a list of all the options in the list (options)
27
Q

What is a dialog box:

A

a box that pops up over a browser window and does not allow access to the underlying window until it has been handled

28
Q

What are user prompts?

A

modal windows requiring users to interact with them before the user can continue to interact with the controls in the browser window itself.

29
Q

Three different alert-type dialogs defined by W3C:

A
  • Alert
  • Confirm
  • Prompt
30
Q

When the “unexpected alert open” error could be returned by a script action?

A

When the script tries to ignore a prompt and continue sending commands to the browser window itself

31
Q

Hows the alert dialog box is often used?

A

to make sure that the user is made aware of some meaningful information.

32
Q

Why alert boxes require special handling?

A

alert dialog boxes are not actually a part of the web page

33
Q

CODE: Create an Alert Object

A

driver.switch_to.alert

34
Q

What are the two ways in that Alert dialogs may be closed?

A
# first Create an Alert Object
# then

A)
alert.accept()
# B)
alert.dismiss()