Home > Enterprise >  How to click on Text link in frame pop up using selenium python?
How to click on Text link in frame pop up using selenium python?

Time:11-04

I am learning selenium for web scraping.I want to click on a link using selenium But could not find a way to do that.The problem is the link opens in a new frame inside a webpage and i can't locate any element on that frame.

I have attached a picture of that pop up frame and source code of that frame.I hope there is a way to solve this issue.enter image description here

enter image description here

enter image description here

the code i have tried :

try:

browser.get('https://imbsmc.invoicing.co/client/payment_methods/create?method=2')

browser.switch_to.frame(0)

myElem_1 = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.LINK_TEXT, 'Manually enter account & routing info')))
myElem_1.click()
except:
      pass

CodePudding user response:

Generally speaking, you must:

  1. first switch to the iframe … driver.switch_to.frame(frame_reference)

  2. do your testing in the iframe

  3. switch back in the main window … driver.switch_to.default_content()

CodePudding user response:

I have translated C# to your langage, not sure about By.Id but you will fix that.

just fyi its not alink but a button, you cant find it by linktext.

browser.maximize_window()
browser.get('https://imbsmc.invoicing.co/client/payment_methods/create?method=2')
frame = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'wepay-ach')))

browser.switch_to.frame(frame);
but = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.ID, 'microdeposit-button')))

but.Click();
  • Related