Home > Net >  How can I fill the form of this popup?
How can I fill the form of this popup?

Time:12-07

I'm just learning Selenium and I wrote this small code. From there, I don't find any way to fill a form. The HTML source of the fill popups appears only when you clic "Créer un compte", "Create an account" in english. But it looks like when I just print(driver.source_page) I don't get this part of the code.

from selenium import webdriver
from selenium.webdriver.common.by import By
import webbrowser

driver = webdriver.Chrome()
driver.get('http://labrute.muxxu.com/')

element = driver.find_element(By.CLASS_NAME,'tid_long')
element.click()

driver.switch_to_frame(driver.find_element_by_css_selector('//*[@id="create"]/div[1]/div[1]/div[1]/div/label'))

Do you have any ideas? Here is the popup Here is without popup Thanks

I tried to use like driver.switch_to xx methods, but nothing worked yet.

CodePudding user response:

It is inside an iframe, you have to switch to the iframe then you have to enter the values:

WebDriverWait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//*[@name='tid_create']")))
time.sleep(1)
driver.find_element(By.XPATH, "//*[@name='name']").send_keys("name")

CodePudding user response:

Thanks for your help, The code finally looks like:

driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR,'#tid_frameWrapper
 > iframe'))

Best regards

  • Related