更改为 iframe Selenium Webdriver 时出现问题

问题描述 投票:0回答:0

我有很大的问题,因为我无法更改为 iframe 来关闭广告 https://www.automationexercise.com/ 我下一步注册需要在输入中输入一些信息,但我不能因为它

我将放置有关定位器的信息:

    button_main_page_adv = '/html/body/ins[2]/div[1]//ins/span/svg/path'
    iframe_src = "https://www.google.com/recaptcha/api2/aframe"
    iframe_element = f"//iframe[contains(@src, '{iframe_src}')]"

页面对象模式方法:

  def switch_to_frame(self):
        self.logger.info("+. Switch to frame")
        self.driver.switch_to.frame(self.driver.find_element(By.XPATH, self.iframe))
        self.driver.find_element(By.XPATH, self.hooveradv).click()
        self.driver.switch_to.default_content()

主要测试项目:

   def test_RegistrationAccountPassed(self): #To klasa dla sprawdzania loginu  poprawnego
        email = str(randint(0, 1000)) + '[email protected]'
        name = str(names.get_full_name(gender ='male'))
        password = str(randint(0, 1000)) + str(names.get_full_name(gender ='female'))
        My_account_page  = Myaccountpage(self.driver)
        My_account_page.open_page()
        My_account_page.switch_to_frame()

告诉我我能做些什么来放下它:p

selenium-webdriver iframe pytest pageobjects
© www.soinside.com 2019 - 2024. All rights reserved.