Selenium webinar

In notebook:
FrontEndMasters Async Javascript
Created at:
Fundamentals JavaScript
Locator etiquette

how to find elements on a page

they recommend using ID to find the element

Resilient: element_by_name
less good: find_element_by_css_selector
brittle: find_elements_by_xpath 

very brittle: to find an element by text content, i.e.. 'sign up today'
​data-​ attribute selector, new in selenium. can work well also
Using Selenium with CBT's Cloud

First test locally. It's quick, easy to learn. 

Then it's easy with minimal changes run the tests on CBT's device cloud. 
Add authentication, and capabilities and define browser parameters
Demo is in Python

He adds a lot of sleeps to the driver so that he can see what's going on (​time.sleep(3)​ in Python.

creates a Chrome target with ​driver = web drive.Chrome()​ then uses ​driver​ to talk to the browser

Then adds a ​try​ and ​finally​. 
You need to make sure you start up and shut down your browser.

Responsive test

uses ​driver.get("http://..")​ to get a page.
then ​driver.set_window_size(...)​ 

Responsive test plus look for items on the page


and also does

​driver.execute_script("...javascript...", e)​ where ​e​ is the found element 

you can for example scroll with ​execute_script​ 

there's also plural

Login form filling


and for the button:

To continue

Then you need to check somehow that you successfully clicked on the element. 

He uses wait until

 ​webdriverwait(driver, 10),until(EC.presence_of_element_located(by.XPATH('path selector')))
Move to a bigger framework

to run on a cloud service

the code is on GitHub 
My question:

- best strategy to wait for elements/pages to load or appear (I'm using webdriverio)
- using screenshot compare (to further automate checking the results)
Visual Testing capabilities