Reputation: 763
I want to write a code to login to the "Origin" platform
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
options = Options()
options.binary_location = "C:/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"
driver = webdriver.Chrome(chrome_options=options)
driver.get("https://www.origin.com/irl/en-us/store")
time.sleep(5)
Menu_Button = driver.find_element_by_xpath("//*[@id='shell']/section/div/nav/div/div[1]/div[2]").click()
Sign_in_Button = driver.find_element_by_xpath("//div[@class='origin-cta-primary origin-telemetry-cta-primary']").click()
time.sleep(10)
Email_Adress = driver.find_element_by_xpath("//input[@name='email']").send_keys("Deneme")
Password = driver.find_element_by_xpath("//input[@name='password']").send_keys("Deneme123")
Login_Button = driver.find_element_by_xpath("//a[@id='logInBtn']").click()
Pressing the "Login" button opens a new window to enter the id password, but I cannot manage it
Upvotes: 0
Views: 73
Reputation: 1410
You can access new windows with driver.window_handles which is just a list with handles to all the driver's current windows. If the driver has only the main window and the login in window, the login window would be driver.window_handles[1].
You can switch the driver to this window with
driver.switch_to.window(driver.window_handles[1])
After that you should be able to process your code
Email_Adress = driver.find_element_by_xpath("//input[@name='email']").send_keys("Deneme")
....
Upvotes: 2
Reputation: 501
I remember reading about this but I can't quite remember, this might point you in the right direction
https://selenium-python.readthedocs.io/navigating.html#moving-between-windows-and-frames
browser=webdriver.Firefox()
[...]
browser.switch_to_window(browser.window_handles[1])
browser.switch_to_window(browser.window_handles[0])
Upvotes: 1