Selenium moving further

Today I will go over some advanced tips for how to interact with elements using javascript and combine selenium with other tools.

element = driver.execute_script(script_string, *args)
element = driver.execute_async_script(script_string,*args)
document.getElementByID('{id}')
document.getElementsByClassName('{className}')
document.querySelector('{selectorName}')
document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-people-page').shadowRoot.querySelector('#importDataDialogTrigger')
document.querySelector('settings-ui').shadowRoot.querySelector('settings-main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('settings-people-page').shadowRoot.querySelector('#importDataDialogTrigger').getAttribute('id')

def choose_date_birthday(self, driver, index):
select_date = Select(self.start_page_elems.find_birthday_date_drop_down_elem(driver))
return select_date.select_by_index(index)

def choose_female_sex(self, driver):
self.start_page_elems.find_female_sex_radio_button(driver).click()
def handle_store_button(self, browser, text_assert):
list_windows = browser.window_handles
if len(list_windows) == 2:
browser.switch_to.window(list_windows[1])
elif len(list_windows) == 3:
browser.switch_to.window(list_windows[2])
assert text_assert in browser.current_url
browser.close()
browser.switch_to.window(list_windows[0])
I will go through simple example with PyAutoGUI:
def test_facebook_icon(self, set_up_browser):
time.sleep(3)
coords = pyautogui.locateOnScreen(‘facebook_icon.PNG’)
pyautogui.click(coords)

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store