I have tried to automatically write login and password icloud.com
Right now I am succesfull click Sign In button. Next I switch to iframe. But can't find element for send.keys(write login, password)
Always have error like this - TypeError: WebDriver.find_element() takes from 1 to 3 positional arguments but 6 were given If I try to find element By.ID or CLASS_NAME without WebDriverWait - Always error can't find element
enter image description here enter image description here
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome
driver.get("https://www.icloud.com")
btn_log_in = driver.find_element(By.CLASS_NAME, "sign-in-button")
btn_log_in.click()
iframe = driver.find_element(By.XPATH, "//div[@class='home-login-component']//iframe[@id='aid-auth-widget-iFrame']")
driver.switch_to.frame(iframe)
sign_in = WebDriverWait(driver, 30).until(EC.text_to_be_present_in_element(By.XPATH, "//span[@id=' apple_id_field_label']"))
sign_in.send_keys('12345678')
Help please, I can't find my mistake 2 days
You have three separate issues causing this to fail.
xpath
lookup, simply remove the leading white spaceEC.text_to_be_present_in_element
incorrectly.send_keys()
on sign_in
as it is a boolean
Addressing all of the above fixes the issue and inserts text into the box
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("https://www.icloud.com")
btn_log_in = driver.find_element(By.CLASS_NAME, "sign-in-button")
btn_log_in.click()
iframe = driver.find_element(By.XPATH, "//div[@class='home-login-component']//iframe[@id='aid-auth-widget-iFrame']")
driver.switch_to.frame(iframe)
#Remove typo, push your locator into a tuple and pass 'Apple ID' as the text to find
sign_in = WebDriverWait(driver, 10).until(EC.text_to_be_present_in_element((By.XPATH, "//span[@id='apple_id_field_label']"), 'Apple ID'))
#Correctly user ActionChains to send_keys
ActionChains(driver).send_keys("abc").perform()