无法单击弹出窗口中的子按钮

我对硒有疑问:


我无法单击由我单击的第一个按钮生成的弹出窗口中包含的按钮。


    from selenium import webdriver

    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.firefox.options import Options


    # Webdriver

    browser = webdriver.Chrome('C:\\Users\\zlell\\PycharmProjects\\PyroLello\\Userbot\\chromedriver.exe')

    browser.get("https://www.eventbrite.com/e/120621788015")


    # This button originates a pop-up

    python_button = browser.find_element_by_xpath('//*[@id="eventbrite-widget-modal-trigger-120621788015"]')


    # Click

    python_button.click()


    # The pop-up with the new button appears


    # Try to find the button included in the pop-up - Doesn't work

    python_button_2 = browser.find_element_by_css_selector("button.eds-btn.eds-btn--button.eds-btn--fill")


    # Click - Doesn't Work

    python_button_2.click()


当年话下
浏览 91回答 1
1回答

慕田峪7331174

添加页面加载后的等待。抓住 iframe 并切换到它。iframe = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.TAG_NAME, "iframe")))browser.switch_to.frame(iframe)python_button_2 =WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "button.eds-btn.eds-btn--button.eds-btn--fill")))进口from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python