How to use test_alert_buttons method in Airtest

Best Python code snippet using Airtest

main (1).py

Source:main (1).py Github

copy

Full Screen

...683 new_window_msg_btn_text = new_window_msg_btn.text684 print(f' Название активной кнопки: {new_window_msg_btn_text}')685686687def test_alert_buttons(browser):688 browser.get('https://demoqa.com/alerts')689 click_button1 = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div[2]/div[2]/div[2]/div[1]/div[2]/button')690 click_button1.click()691 sleep(3)692 alert = browser.switch_to.alert693 alert_text = alert.text694 print(alert_text)695 assert alert_text == 'You clicked a button'696 alert.accept()697698 click_button2 = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div[2]/div[2]/div[2]/div[2]/div[2]/button')699 click_button2.click()700 alert2 = WebDriverWait(browser, 10).until(EC.alert_is_present())701 alert2_text = alert2.text702 print(alert2_text)703 assert alert2_text == 'This alert appeared after 5 seconds'704 alert2.accept()705706 click_button3 = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div[2]/div[2]/div[2]/div[3]/div[2]/button')707 click_button3.click()708 alert3 = WebDriverWait(browser, 10).until(EC.alert_is_present())709 alert3_text = alert3.text710 print(alert3_text)711 assert alert3_text == 'Do you confirm action?'712 alert3.accept()713714 click_button4 = browser.find_element(By.XPATH, '/html/body/div[2]/div/div/div[2]/div[2]/div[2]/div[4]/div[2]/button')715 click_button4.click()716 alert4 = WebDriverWait(browser, 10).until(EC.alert_is_present())717 alert4_text = alert4.text718 print(alert4_text)719 assert alert4_text == 'Please enter your name'720 alert4.accept()721 my_browser.quit()722723my_browser = init_browser()724725test_button(my_browser)726test_dynamic_btn(my_browser)727test_getting_to_textbox(my_browser)728test_uploading_files(my_browser)729test_clickable_buttons(my_browser)730test_waiting_for_element(my_browser)731test_adding_user(my_browser)732test_edit_user(my_browser)733test_search_box(my_browser)734test_deleting_user(my_browser)735generate_user(my_browser)736adding_10_users(my_browser)737test_new_tab(my_browser)738test_alert_buttons(my_browser) ...

Full Screen

Full Screen

test_ios.py

Source:test_ios.py Github

copy

Full Screen

...149 def test_alert_dismiss(self):150 print("test_get_alert_dismiss")151 self.ios.alert_dismiss()152 @unittest.skipIf(skip_alert_flag, "demonstrating skipping get_alert_buttons")153 def test_alert_buttons(self):154 print("test_get_alert_buttons")155 print(self.ios.alert_buttons())156 print(self.ios.driver.alert.text)157 @unittest.skipIf(skip_alert_flag, "demonstrating skipping get_alert_click")158 def test_alert_click(self):159 print("test_get_alert_click")160 self.ios.alert_click(['设置', '允许', '好'])161 @unittest.skipIf(skip_alert_flag, "demonstrating skipping get_alert_click")162 def test_alert_watch_and_click(self):163 with self.ios.alert_watch_and_click(['Cancel']):164 time.sleep(5)165 # default watch buttons are166 # ["使用App时允许", "好", "稍后", "稍后提醒", "确定", "允许", "以后"]167 with self.ios.alert_watch_and_click(interval=2.0): # default check every 2.0s...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful