FE Automation Flashcards

1
Q

Selenium Webdriver

A

Is an API and protocol that defines a language-neutral interface for controlling the web browsers. This is as if a real user is operating the browser.

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

Xpath

A

Is the language to query XML documents using XML path expression

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

Methods in Xpath

A
  • contains() - uses partial value
  • starts-with()
  • text() - has to be an absolute text, not partial
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Implicit wait

A

The driver is asked to wait for a specific amount of time for the element to be available in the DOM page

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

Syntax for implicit wait

A

driver.implicitly_wait(2)

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

Explicit wait

A

The driver is asked to wait until a certain condition is satisfied

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

Locators

A

Are addresses that identify a web element uniquely within the page

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

Types of basic locators

A
  • ID
  • NAME
  • LINK_TEXT, PARTIAL_LINK_TEXT
  • CLASS_NAME
  • TAG_NAME
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Types of customized locators

A
  1. CSS Selector
    - Tag and ID
    - Tag and Class
    - Tag and attribute
    - Tag, class and attribute
  2. XPath
    - Absolute XPath
    - Relative XPath
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is tag name

A

Input, select, head, body, div…

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

Attributes in html

A

Is a piece of markup language used to adjust the behavior or display of an HTML element.
Example: name, ID, class

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

linkText or partialLinkText

A

The text from the web page and not from the html

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

How to find multiple elements

A

driver.findElements

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

How to return the number of elements

A

With len method
Example: number=driver.findElements…..
print(len(number)

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

What elements being retuned as multiple

A

Tags, classes

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

Syntax to use locators

A

from selenium.webdriver.common.by import By

driver.findElement(By.ID(“name”)

Can also be used for CLASS_NAME, TAG_NAME, NAME, LINK_TEXT, PARTIAL_LINK_TEXT)

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

Syntax to use CSS selector

A

driver.findElement(By.CSS_SELECTOR(“#email))

tag# - id
tag. - class
attribute - “tag[name=email]”

tag, class, attribute- (“input.inputtext[data-testid=royal_email]”)

tag is always optional

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

DOM

A

Document object model is an API interface provided by the browser. When a web page is loaded, the browser created a DOM of the page.

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

Types of XPath

A
  • absolute(full)
  • relative(partial)
20
Q

What is absolute XPath

A

The complete path beginning from the root to the element witch we want to identify. XPath becomes invalid if there are any changes in attributes from the root to the element.
Starts with single slash: /

21
Q

What is relative XPath

A

Starts from the element. Works based on certain attributes and value.
Starts with double slash: //

22
Q

Difference between absolute and relative XPath

A
  1. Absolute XPath starts from the root node and relative directly jumps to element in DOM
  2. Absolute starts with single slash /, relative with double slash //
  3. Absolute uses only tags/nodes, relative uses attributes
23
Q

Fluent wait selenium

A

It’s the maximum amount of time for the driver to wait for a certain condition to become visible, as well as frequency with which to check the condition.
User may configure the wait to ignore specific type of exceptions.

24
Q

Syntax to go forward with selenium

A

driver.navigate().forward()

25
Q

Syntax to navigate back with selenium

A

driver.navigate().back()

26
Q

POM

A

Is a structural design pattern that groups UI web elements into classes or repositories that allows us to reuse these segments in other pieces of our codes. It separates the test logic from the finding elements logic

27
Q

Selenium suite components

A
  • selenium IDE
  • selenium RC(remote control)
  • selenium WebDriver
  • selenium Grid
28
Q

Syntax to navigate to the provided URL

A

driver.navigate().to(“https….”)

29
Q

Difference between driver.close() and driver.quit()

A
  • driver.close() - closes the current window
  • driver.quit() - closes all the open browser windows
30
Q

How to type in the input box using selenium

A

Using .send_keys() method

31
Q

How to click in hyperlink using selenium

A

Using linkText or PartialLinkText locator and click() method

32
Q

How to scroll down with selenium

A

With JS executor:
driver.executeScript
(“window.scrollTo(0,Y)”)
Y - the height
Example:
- 600
- document.body.scrollHeght

33
Q

How to maximize the window

A

driver.maximize_window()

34
Q

How to assert the title of a webpage with selenium

A

with driver.title method

35
Q

Sleep method in Python

A

Suspends execution for the given number.
import time
time.sleep(5)

36
Q

How to hover over element selenium

A

With ActionChains
1. Import ActionChains
from selenium.webriver.common.actions_chains import ActionChains
2. Identify elements to hover: hover_el
3. Instantiate action object:
a = ActionChains(driver)
4. Perform the action:
a.move_to_element(hover_el).perform()

37
Q

How to locate element by attribute with XPath

A

//*[contains(@attribute, “name”)]

38
Q

How to retrieve css properties of an element

A

element.value_of_css_property(“property”)

39
Q

What is Captcha and can it be automated

A

Is a security feature that prevents bots and automated programs from accessing sensitive information
It can not be automated, has to be done manually

40
Q

How does selenium handle windows based pop-ups

A

Windows based features are not natively supported by Selenium.
It can be done with third party tools like AutoIT, Robot

41
Q

How to take a screenshot with selenium

A

driver.save_screenshot(“image.png”)

“./images/image.png” - to save it in the folder

42
Q

How to select drop-down using selenium

A

Using Select
1. import Select: from selenium.webdriver.suport.select import Select
2. Locate the element:
el = Select(driver.find_element…)
3. Perform action:
- el.select_by_index(0)
- el.select_by_visible_text(‘text’)
- el.select_by_value(“value”) - from the code

43
Q

Switching windows in selenium

A

With switch_to_window() and driver.window_handles[] methods
1. Identify original window:
first=driver.window_handles[0]
2. Locate and click on the second window
3. Identify second window:
second=driver.window_handles[1]
4. Switch to the first window:
driver.switch_to_window(first)

44
Q

How to print window id’s with multiple windows in selenium

A

print(driver.window_handles)

45
Q

How to get and change the size of the window with selenium

A

Get the size:
driver.get_window_size()
Set size:
driver.set_window_size(width, height)

46
Q

How to login into any site with authentication pop up for username and password

A

By passing username and password in the URL
driver.get(“http://“+username+”:”+password+”@“+”httpbin.org/basic-auth/user/passwd”

47
Q

Syntax for relative expressions in XPath

A
  • //tagname[@attribute=“value”]
  • //tagname[@attribute=“value” and @attribute=“value”] - with multiple attributes
  • //tagname[text()=‘value’]
  • //tagname[contains(text(), ‘value’)]
  • //tagname[@attribute=“value”] //tagname[@attribute=“value”] - multiple tags
  • //* [@attribute=“value”], *- all tags
    Sibling XPath:
  • presiding-sibling, forward-sibling, parent
  • //tagname[text()=‘value’]//parent::td[@attribite=‘value’]//preceding-sibling::td[@attribute=‘value’]//tagname[@attribute=‘value’]
    Command+F- XPath window