在Selenium中,我的ENV和Python代码是正确的,但在自动化过程中我遇到了一个错误

6l7fqoea  于 5个月前  发布在  Python
关注(0)|答案(1)|浏览(51)

我在练习自动化测试(Selenium with Python)登录Redhat Academy的网站。然而,在自动化过程中,我在终端中遇到错误。我相信我的代码和内部系统设置是正确的。(我已经在不同的网站上测试过了,比如Facebook,Riot,和一些虚拟的自动化实践网站).我附上两个截图-一个是我的代码,另一个是Redhat网站的inspect视图。* [* 只是想提一下,我还没有完全完成使用Python学习Selenium的过程,所以我可能会在编码过程中犯一些错误。]
x1c 0d1x的数据



我试图在红帽登录页面字段中写入名为“红帽登录或电子邮件”的内容。


xe55xuns

xe55xuns1#

告诉我这个是否有效。我换了几个零件。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Firefox()
driver.maximize_window()

driver.get("https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/auth?client_id=cloud-services&redirect_uri=https%3A%2F%2Fconsole.redhat.com%2F&state=e6a1436a-7cbc-4245-8289-cf84fe701743&response_mode=fragment&response_type=code&scope=openid&nonce=41932180-acf3-4b0a-928d-60bd3154bc6a")  # I am assuming this is the correct starting page you can change as you want

login_link = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//a[@href='https://console.redhat.com/' and @title='Log in']"))
)
login_link.click()

username_field = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.XPATH, "//*[@id='username-verification']"))  # Updated XPath
)
username_field.send_keys("HELLO")  # Replace with your actual username

# Assuming the form has an ID of "login-form"
form = driver.find_element(By.ID, "login-form")
form.submit()

字符串

相关问题