I have one web site like www.abc.com in this I need to add Email and press continue and in second page I need to add password and check the check box so how can I enter the password in 2nd page.
I tired with :
JavaScript
x
18
18
1
from selenium import webdriver
2
from selenium.webdriver.common.action_chains import ActionChains
3
4
from selenium.webdriver.common.keys import Keys
5
uamId = "asas"
6
7
driver = webdriver.Chrome("chromedriver")
8
driver.get("www.abc.com")
9
print(driver.title)
10
userid = driver.find_element_by_name("P")
11
# fill UAM Number
12
userid.send_keys(a)
13
14
elem = driver.find_element_by_xpath('Xpath')
15
16
actions = ActionChains(driver)
17
actions.click(elem).perform()
18
Advertisement
Answer
Before getting the web element you have to validate the element is fully loaded and is clickable / visible.
Also in that specific site you have to click elements in order to insert the email and password.
Your code should look like this:
JavaScript
1
21
21
1
from selenium import webdriver
2
from selenium.webdriver.common.action_chains import ActionChains
3
from selenium.webdriver.common.by import By
4
from selenium.webdriver.support.ui import WebDriverWait
5
from selenium.webdriver.support import expected_conditions as EC
6
from selenium.webdriver.common.keys import Keys
7
8
driver = webdriver.Chrome("chromedriver")
9
wait = WebDriverWait(driver, 20)
10
driver.get("www.abc.com")
11
print(driver.title)
12
#open account menu
13
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".navigation__menu #account span"))).click()
14
wait.until(EC.visibility_of_element_located((By.XPATH, "//a[text()='Sign in']"))).click()
15
#now you will have to switch into the iframe
16
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='disneyid-iframe']")))
17
#now you can insert the credentials
18
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type='email']"))).send_keys(your_email)
19
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[type='password']"))).send_keys(your_password)
20
21