我正在使用Selenium(Python),并试图将自己登录到不和谐的网站(https://discordapp.com/login)中,但是我所有的代码只是加载页面而已。我尝试了所有Css选择器XPath EVERYTHING。有人有建议吗?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get('https://discordapp.com/login')
assert 'discordapp' in browser.title
elem = browser.find_element_by_css_selector("input[type='email']")
elem.send_keys("itsolidude@gmail.com")
elem1 = browser.find_element_by_css_selector("input[type='password']")
elem1.send_keys("password" + Keys.ENTER)
答案 0 :(得分:1)
尝试下面的代码,在其中添加同步并在Firefox上使用进行了测试 python。
您必须添加以下导入
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
代码:
url = "https://discordapp.com/login"
driver.get(url)
email = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"//input[@type='email']")))
email.send_keys("test@test.com")
答案 1 :(得分:0)
只需在代码中添加您的凭据:)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
driver = webdriver.Chrome()
driver.get("https://discord.com/login")
time.sleep(6)
username_input = driver.find_element_by_name('email')
username_input.send_keys("enter-your-username-here")
password_input = driver.find_element_by_name('password')
password_input.send_keys("Enter-your-password-here")
login_button = driver.find_element_by_xpath('//*[@id="app-mount"]/div[2]/div/div[2]/div/div/form/div/div/div[1]/div[3]/button[2]')
login_button.click()