Weird Python Selenium Button Click Behaviour

后端 未结 1 1146
小鲜肉
小鲜肉 2021-01-17 06:56

The part I\'m trying to click:

相关标签:
1条回答
  • 2021-01-17 07:39

    Try this xpath (updated with code block SO site removed my *)

    //*[contains(concat(' ', @class, ' '), ' btns right ')]//*[contains(concat(' ', @class, ' '), ' expand-all ') and contains(text(), 'View All Cards')]

    Provide some wait for the element to be clickable(implicit is recommended).

    I have Used Only for java , But I refered here for python here it may help!!

    from selenium.webdriver.support import expected_conditions as EC
    
    wait = WebDriverWait(driver, 10)
    button = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[contains(concat(' ', @class, ' '), ' btns right ')]//*[contains(concat(' ', @class, ' '), ' expand-all ') and contains(text(), 'View All Cards')]')))
    button.click()
    
    
    Even if the above thing fails, try this
    

    form these links link1 and link2

    driver.execute_script("document.getElementsByClassName('expand-all')[0].click();")
    

    inject an artificial CLICK on the desired element, remove(comment) all other codes

    May be ur app falls under link2 OP :)

    0 讨论(0)
提交回复
热议问题