python - 如何使用python登录
问题描述
我有这个代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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
import time
path = r'C:\Users\test\Documents\Python Scripts\chromedriver.exe'
driver = webdriver.Chrome(path)
driver.get("http:\\www.wyzant.com")
link = driver.find_element_by_link_text("LOG IN")
link.click()
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "username")))
username = driver.find_element_by_id("Username")
username.send_keys("test")
该代码未将“测试”发送到用户名 ID。我想一旦我能够插入用户名,我应该能够弄清楚如何插入密码并单击登录。
解决方案
在javascript中我使用这个函数|
const button = await driver.wait(
until.elementLocated(By.xpath('your xpath element')), 12000).then(button => {
return driver.wait(until.elementIsVisible(button4),12000)}, function(button4) {
if (button instanceof Error) {
bot.sendMessage(-*****chatID,"Card info"+console.log(button)+"CRASH!⛔️");
console.log(button, 'fail');
console.log(Date(time));
return WebDriver.quit();
}
})
button.sendKeys('your text').then(async function() {
console.log(button.sendKeys,'input info - done');
return true//it existed
})
推荐阅读
- tikz - Tikz 思维导图覆盖特定节点的水平距离和同级角度
- amp-html - rtc-config 参数被剥离
标签 - php - 在 PHP 中验证链接
- xamarin.ios - Azure AD 2.0 oauth 不重定向
- android - Recycleview 显示灰色区域
- c# - ClaimsIdentity 用户在测试期间未被识别为已登录
- python - 将处理中出现错误的所有行移到另一个数据框中?
- mysql - 在 phpMyAdmin 中上传大型数据库
- scroll - Anychart ScrollBar 在 AnyGantt 资源网格中的内容之上
- java - 使用 PowerMockRunner 和 LocalDate 类来模拟今天的日期