不单击选项卡TimeoutException(message,screen,stacktrace)

时间:2017-12-26 02:20:20

标签: python python-3.x selenium xpath selenium-webdriver

我在下面有一个脚本点击某些按钮然后它给出:

  

第41行,在clickMe = wait(driver,
  15).until(EC.element_to_be_clickable((By.XPATH,'(// * [@ class =" KambiBC-collapsible-container KambiBC-mod-event-group-container"])[ %s]'%str(index + 1))))行   80,直到引发TimeoutException(消息,屏幕,堆栈跟踪)
  selenium.common.exceptions.TimeoutException:消息:

我已尝试将xpath更改为//*[@class="KambiBC-mod-event-group-header__event-count"]并增加等待时间。

但它一直给出这个错误信息。 知道如何解决这个问题所以我可以点击该页面上的所有标签吗?

from random import shuffle

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

driver = webdriver.Chrome()
driver.set_window_size(1024, 600)
driver.maximize_window()

driver.get('https://www.unibet.com.au/betting#filter/football')
options = driver.find_elements_by_xpath('//div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"]')

def page_counter():
    for x in range(1000):
        yield x

count = page_counter()

clickMe = wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, ('//div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"]'))))
#//*[@class="KambiBC-mod-event-group-header__event-count"]
import collections
coupon_lables = driver.find_elements_by_xpath('//div[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"]')
coupon_lables = [index for index in range(len(coupon_lables))]
shuffle(coupon_lables)
links = dict((next(count) + 1, e) for e in coupon_lables)
desc_links = collections.OrderedDict(sorted(links.items(), reverse=True))
for key, index in desc_links.items():
    clickMe = wait(driver, 15).until(EC.element_to_be_clickable((By.XPATH,'(//*[@class="KambiBC-collapsible-container KambiBC-mod-event-group-container"])[%s]' % str(index + 1))))
    driver.execute_script("arguments[0].scrollIntoView();", clickMe)
    clickMe.click()

0 个答案:

没有答案