Selenium自动化测试框架如何处理弹窗? | i人事-智能一体化HR系统

Selenium自动化测试框架如何处理弹窗?

selenium自动化测试框架

  from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC

  driver = webdriver.Chrome()
  driver.get("your_test_url")
  # 模拟触发modal弹窗的动作
  driver.find_element(By.ID, "openModalButton").click()

  # 等待modal出现
  WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "myModal")))

  modal = driver.find_element(By.ID, "myModal")
  close_button = modal.find_element(By.CLASS_NAME, "close")
  close_button.click()

原创文章,作者:IamIT,如若转载,请注明出处:https://docs.ihr360.com/biz_and_flow/biz_flow/29512

(0)