I am connecting with Python to the following webpage
https://webgate.ec.europa.eu/fsd/fsf#!/files
I have written the following Python code:
import pandas as pd
import numpy as np
from datetime import date
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
import time
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
if True:
chromedriver_path = r"./driver/chromedriver"
browser = webdriver.Chrome(executable_path=chromedriver_path)
url = "https://webgate.ec.europa.eu/fsd/fsf#!/files"
browser.get(url)
escolhe = browser.find_element("xpath", topics_xpath)
time.sleep(10)
escolhe.click()
time.sleep(60)
browser.close()
The web page opens up and I am prompted to enter the user ID (which is my e-mail address).
Question 1. How do I enter the password and click on Next from Python?
After I will have managed to do that, I will prompted to enter my password and to click on Next.
Question 2. How do I enter my password and click on Next from Python?
Can someone help me please?
I write some codes to finish it.
because I have no account, so you should finish type password by yourself.
"send_keys" is typing your account
"WebDriverWait" is wait until next can be clicked
"click" is to click the button of next
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver import EdgeOptions
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import os
def edgeopen(driverpath):
service=Service(executable_path=driverpath)
edge_options = EdgeOptions()
#https://stackoverflow.com/questions/53039551/selenium-webdriver-modifying-navigator-webdriver-flag-to-prevent-selenium-detec
edge_options.add_experimental_option('excludeSwitches', ['enable-automation'])
edge_options.add_experimental_option('useAutomationExtension', False)
edge_options.add_argument('lang=zh-CN,zh,zh-TW,en-US,en')
# edge_options.add_argument('--window-size=1920,1080')
edge_options.add_argument('--disable-gpu')
# edge_options.add_argument('start-maxmized')
edge_options.add_argument("disable-blink-features=AutomationControlled")#就是这一行告诉chrome去掉了webdriver痕迹
edge_options.page_load_strategy = 'normal'
driver = webdriver.Edge(options=edge_options, service = service)
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36'})
driver.set_script_timeout(130)
return driver
def fillnamepassword(driver):
driver.find_element(By.XPATH, r"/html/body/div[3]/div/div/div/div/div[2]/form/input").send_keys("username@gmail.com")
WebDriverWait(driver, timeout=10).until(EC.element_to_be_clickable((By.XPATH, r"/html/body/div[3]/div/div/div/div/div[2]/form/div[2]/div[2]/button")))
driver.find_element(By.XPATH, "/html/body/div[3]/div/div/div/div/div[2]/form/div[2]/div[2]/button").click()
time.sleep(130)
def login():
website = r'https://ecas.ec.europa.eu/cas/login'
driverpath = r'C:\Users\10696\Desktop\csdn\edgedriver'
driver = edgeopen(driverpath)
driver.get(website)
fillnamepassword(driver)
driver.quit()
if __name__=="__main__":
login()