繁体   English   中英

python splinter无法单击页面上的css元素

[英]Python splinter cant click on element by css on page

我正在尝试使用碎片自动在旅游网站上进行预订,并且在单击页面上的CSS元素时遇到麻烦。

这是我的代码

import splinter
import time

secret_deals_email = {
    'user[email]': 'adf@sad.com'
}

browser = splinter.Browser()
url = 'http://roomer-qa-1.herokuapp.com'
browser.visit(url)
click_FIND_ROOMS = browser.find_by_css('.blue-btn').first.click()
time.sleep(10)
# click_Book_button = browser.find_by_css('.book-button-row.blue-btn').first.click()
browser.fill_form(secret_deals_email)
click_get_secret_deals = browser.find_by_name('button').first.click()
time.sleep(10)
click_book_first_room_list = browser.find_by_css('.book-button-row-link').first.click()
time.sleep(5)
click_book_button_entry = browser.find_by_css('.entry-white-box.entry_box_no_refund').first.click()

问题是,每当我运行它时,代码就会到达需要单击所需购买类型的页面。 我无法单击页面上的任何选项。

无论我该怎么办,我都会不断发现该元素不存在的错误。

http://roomer-qa-1.herokuapp.com/hotels/atlanta-hotels/ramada-plaza-atlanta-downtown-capitol-park.h30129/44389932?rate_plan_id=1&rate_plan_token=6b5aad6e9b357a3d9ff4b31acb73c620&

这是导致我麻烦的页面的链接,请帮助:)。

您需要花时间,直到该元素出现在网站上。 您可以将is_element_not_present_by_css方法与while循环结合使用来实现

while not(is_element_not_present_by_css('.entry-white-box.entry_box_no_refund')):
  time.sleep(50)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM