셀레늄 자동화 봇을 코딩하고 있는데 iFrame에서받은 입력에 키를 보내고 싶습니다. 코드 줄을 확인합니다.
username = bot.find_element_by_xpath("//iframe[@title='Registration form' and @class='top']")
도와 주실 수 있나요? 입력을 클릭 할 수 있지만 키를 보낼 때 작동하지 않고 입력 필드를 선택 취소합니다.
당신은 보내지 않는 문자 순서를 받는 <iframe>
대신 보낼 것이다 요소 문자 순서를 받는 <input>
내 요소 <iframe>
. 원하는 요소가 안에 <iframe>
있으므로 다음을 수행해야합니다.
원하는 frameToBeAvailableAndSwitchToIt에 대해 WebDriverWait 를 유도합니다 .
원하는 elementToBeClickable에 대해 WebDriverWait 를 유도 합니다 .
다음 로케이터 전략 중 하나를 사용할 수 있습니다 .
사용 XPATH
:
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='Registration form' and @class='top']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@attribure_name='attribute_value']"))).send_keys("Igor Duca")
사용 CSS_SELECTOR
:
driver.get('https://www.t-online.de/themen/e-mail')
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.top[title='Registration form']")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[attribure_name='attribute_value']"))).send_keys("Igor Duca")
참고 : 다음 가져 오기를 추가해야합니다.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Python Selenium의 클래스에서 모든 href를 추출하는 방법 에서 관련 자세한 토론을 찾을 수 있습니다 .
다음에서 몇 가지 관련 토론을 찾을 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다