Python Selenium元素不可点击 [英] Python Selenium Element is not clickable
问题描述
我尝试使用Python 3.6和Selenium收集网站上的信息,但是,该页面立即在Chrome上加载(54.0.2840.87(64位)),它会转到选项卡(Case Logs)半秒钟,然后它变成另一个标签(警报)。
I'm trying to gather the information on a website using Python 3.6 and Selenium, however, the page loads right away on Chrome(54.0.2840.87(64-bit)), it goes to the tab(Case Logs) for half second, then it changes to another tab(Alerts).
我试图用'find_element_by'找到它,点击某个点,找到标签上的文字(案例日志)。如果我使用'find_element_by_xpath',则得到'元素在点(488,93)不可点击。其他元素会收到点击'。
I tried to find it using 'find_element_by', clicking at certain point, finding the text on the tab(Case Logs). If I use 'find_element_by_xpath', I get 'Element is not clickable at point (488, 93). Other element would receive the click'.
以下是代码:
Here is the code:
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
#enter credentials
user = input('User: ')
password = input('Password: ')
case = input('Case: ')
#open the page
driver= webdriver.Chrome()
driver.maximize_window()
driver.get('.com')
#login
elem = driver.find_element_by_id("user")
elem.send_keys(user)
elem = driver.find_element_by_id("password")
elem.send_keys(password)
elem.send_keys(Keys.RETURN)
#Find Case
elem = driver.find_element_by_id("searchCaseIdHome")
elem.send_keys(case)
elem.send_keys(Keys.RETURN)
#Find Notes
elem = driver.find_element_by_xpath("//*[@id='ext-gen151']")
elem.click()
https://i.stack.imgur.com/wIG7V.png
https://i.stack.imgur。 com / aUmTN.png
推荐答案
elem = driver.find_element_by_xpath("//*[@id='ext-gen151']")
elem.location_once_scrolled_into_view
elem.click()
这篇关于Python Selenium元素不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!