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 我能';由于框架的原因,找不到元素_Python_Selenium - Fatal编程技术网

Python 我能';由于框架的原因,找不到元素

Python 我能';由于框架的原因,找不到元素,python,selenium,Python,Selenium,我正试图设计一个自动预订系统。 所以我需要找到一个元素:driver.find\u element\u by\u link\u text(“予約可"). 如果加载后元素可见,我可以找到该元素。 (在代码示例中,表示元素位于该范围02:00-05:30) 所以我试着找到框架,但是失败了。我已经试着找到解决方案两天了 from selenium import webdriver from selenium.common.exceptions import NoSuchElementException

我正试图设计一个自动预订系统。 所以我需要找到一个元素:driver.find\u element\u by\u link\u text(“予約可").

如果加载后元素可见,我可以找到该元素。 (在代码示例中,表示元素位于该范围02:00-05:30) 所以我试着找到框架,但是失败了。我已经试着找到解决方案两天了

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException 


driver = webdriver.Chrome()

url = 'https://eikaiwa.dmm.com/list/?data%5Btab1%5D%5Bstart_time%5D=02%3A00&data%5Btab1%5D%5Bend_time%5D=25%3A30&data%5Btab1%5D%5Bgender%5D=0&data%5Btab1%5D%5Bage%5D=%E5%B9%B4%E9%BD%A2&data%5Btab1%5D%5Bfree_word%5D=Kim+Khim&date=2019-06-13&tab=0&sort=6'

driver.get(url)   


try:
    button = driver.find_element_by_link_text("予約可")
    driver.execute_script("arguments[0].scrollIntoView(false);", button) # move to the position of the button    
except NoSuchElementException:
    print('not found any opening')


所需元素未滚动,因此无法交互

可以通过以下方式找到该元素:

button.location_once_scrolled_into_view
但是我找不到链接文本,而是找到了类名

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException 

driver = webdriver.Chrome()

url = 'https://eikaiwa.dmm.com/list/?data%5Btab1%5D%5Bstart_time%5D=02%3A00&data%5Btab1%5D%5Bend_time%5D=25%3A30&data%5Btab1%5D%5Bgender%5D=0&data%5Btab1%5D%5Bage%5D=%E5%B9%B4%E9%BD%A2&data%5Btab1%5D%5Bfree_word%5D=Kim+Khim&date=2019-06-13&tab=0&sort=6'

driver.get(url)   

try:
    #button = driver.find_element_by_link_text("予約可")
    button = driver.find_element_by_class_name("bt-open")
    button.location_once_scrolled_into_view
    button.click()
except NoSuchElementException:
    print('not found any opening')
页面上有12个元素,文本为“予約可. 您要单击哪个
按钮()