Python Selenium Element不可点击

时间:2016-11-06 00:03:17

标签: python google-chrome selenium

我尝试使用Python 3.6和Selenium在网站上收集信息,然而,页面立即加载到Chrome(54.0.2840.87(64位)),它会转到标签页(Case Logs) )半秒钟,然后它变为另一个标签(警报)。

我尝试使用' find_element_by'找到它,在某一点点击,找到标签上的文字(案例日志)。如果我使用' find_element_by_xpath',我得到'元素在点(488,93)处不可点击。其他元素将收到点击“

以下是代码:

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

1 个答案:

答案 0 :(得分:-1)

elem = driver.find_element_by_xpath("//*[@id='ext-gen151']")
elem.location_once_scrolled_into_view
elem.click()