I have this code:
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")
The code isn't sending "test" into the username id. I think once I'm able to plug in the username, I should be able to figure out how to plug in the password and click login.
CodePudding user response:
There are two things to change here. The element id is Username
not username
and using find_element_by_css_selector
seems to work.
So, changes will be as below
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "Username")))
username = driver.find_element_by_css_selector(".sso-login-form > div:nth-child(2) > input:nth-child(2)")
CodePudding user response:
in javascript i use this function |
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
})