Нужно отправить код hcapthca, но selenium бот не видит поле для ввода и оно не становится видимым какими-либо эвентами. Можно сделать так, чтобы selenium начал видеть это окно ввода? Вот код:
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
import selenium.webdriver.support.expected_conditions as ec
url_login = '
https://www.epicgames.com/id/login?lang=ru&noHostR...'
browser = webdriver.Chrome()
def get_password_or_email(password_or_email: str):
if password_or_email == 'password':
with open('pass_email.txt', 'r') as file:
line: str = file.read()
return line.split(':')[1]
elif password_or_email == 'email':
with open('pass_email.txt', 'r') as file:
line: str = file.read()
return line.split(':')[0]
def main():
try:
#login with epic
browser.get(url_login)
action = ActionChains(browser)
login_with_epic_btn = WebDriverWait(browser, 100).until(ec.element_to_be_clickable((By.XPATH, '//*[@id="login-with-epic"]')))
action.move_to_element(login_with_epic_btn).click().perform()
#window login
email_key = get_password_or_email('email')
password_key = get_password_or_email('password')
email_input = WebDriverWait(browser, 100).until(ec.visibility_of_element_located((By.ID, 'email')))
password_input = WebDriverWait(browser, 100).until(ec.visibility_of_element_located((By.ID, 'password')))
remember_me_btn = WebDriverWait(browser, 100).until(ec.element_to_be_clickable((By.XPATH, '//*[@id="modal-content"]/div[2]/div/form/div[3]/label/span[1]')))
action.move_to_element(remember_me_btn).click()
action.send_keys_to_element(email_input, email_key).perform()
action.send_keys_to_element(password_input, password_key).perform()
login_btn = WebDriverWait(browser, 100).until(ec.element_to_be_clickable((By.XPATH, '//*[@id="sign-in"]')))
action.move_to_element(login_btn).click().perform()
time.sleep(1)
# browser.execute_script("document.querySelector('#h-recaptcha-response-0gkzbd3mb5m6').setAttribute('style', 'width: 250px; height: 80px; border: 1px solid rgb(193, 193, 193); margin: 0px; padding: 0px; resize: none;')")
time.sleep(10000)
finally:
browser.quit()
if __name__ == '__main__':
main()
^^^^^^
selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot read properties of null (reading 'setAttribute')