Problem with changing to iframe Selenium Webdriver

22 Views Asked by At

I have big problemy, because i cant change to iframe to turn off advertisement on https://www.automationexercise.com/ i next step registration i need put some information in inputs and i cant becasue of it

I will put information about locators:

    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}')]"

Page object patter method:

  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()

And main test project:

   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()

To tell me what i can do to put it down :p

0

There are 0 best solutions below