Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中找不到selenium中的元素_Python_Selenium_Google Chrome_Stack_Chromium - Fatal编程技术网

在python中找不到selenium中的元素

在python中找不到selenium中的元素,python,selenium,google-chrome,stack,chromium,Python,Selenium,Google Chrome,Stack,Chromium,在定位元素之前,您缺少等待条件/延迟。 添加以下内容: from selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager # Initiate the browser browser = webdriver.Chrome(ChromeDriverManager().install()) # Open the Website browser.get("https://lp

在定位元素之前,您缺少等待条件/延迟。
添加以下内容:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager


# Initiate the browser
browser  = webdriver.Chrome(ChromeDriverManager().install())

# Open the Website
browser.get("https://lpsc.codetantra.com/login.jsp")

codetantra_name="JE7-202@lpsc-ab.com"
codetantra_password="AB0707"

browser.find_element_by_name("loginId").send_keys(codetantra_name)

browser.find_element_by_name("password").send_keys(codetantra_password)

browser.find_element_by_class_name("pull-right").click()

browser.find_element_by_xpath("//*[@id='homeCenterDiv']/div/div[1]/div/div[2]/a").click()


之后,您可以正常填写密码并单击登录按钮。您需要引入webdriverwait来完成此项工作。要单击的元素是文本节点。但这不是一个普通的文本。 请查看以下代码:

代码:

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

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.NAME, "loginId"))).click()

您的答案没有以合适的格式显示代码,请对其进行修改,以便于其他用户阅读。除了清楚之外,它还必须说明错误发生的位置、错误消息以及您以前尝试过的选项。在这种情况下,了解网页的html内容可能会很有帮助。请快速帮助,它没有显示这样的元素。错误:消息:没有这样的元素:无法定位元素:{“方法”:“xpath”,“选择器”:“/*[@id='homeCenterDiv']]/div/div/div[1]/div/div/div[2]/a”}(会话信息:chrome=90.0.4430.212)嘿,它不起作用,我已经尝试过了!我说的是这个:浏览器。通过xpath(“/*[@id='homeCenterDiv']/div/div[1]/div/div[2]/a”)查找元素。单击()什么具体不起作用?webdriver延迟不起作用当某个不起作用的东西正常出现一些错误时,它不会说“我不起作用”消息:没有这样的元素:无法找到元素:{“方法”:“链接文本”,“选择器”:“}(会话信息:chrome=90.0.4430.212)它给出了这个错误。不要生气,我是新来的
    driver = webdriver.Chrome("C:\\Users\\Inc\\Desktop\\Selenium+Python\\chromedriver.exe")
    driver.maximize_window()
    wait = WebDriverWait(driver, 30)
    driver.get('https://lpsc.codetantra.com/login.jsp')
    codetantra_name="JE7-202@lpsc-ab.com"
    codetantra_password="AB0707"
    
    driver.find_element_by_name("loginId").send_keys(codetantra_name)
    
    driver.find_element_by_name("password").send_keys(codetantra_password)
    
    driver.find_element_by_id("loginBtn").click()
    
    button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[role='button'][title='Click here to view Meetings']")))
    button.click()