-1

このコードを使用して、splinter のクリック ボタン オプションを確認しました。

from splinter import Browser

    with Browser() as browser:
    # Visit URL
    url = "http://www.google.com"
    browser.visit(url)
    browser.fill('q', 'splinter - python acceptance testing for web applications')
    # Find and click the 'search' button
    button = browser.find_by_name('btnG')
    # Interact with elements
    button.click()
    if browser.is_text_present('splinter.readthedocs.org'):
        print("Yes, the official website was found!")
    else:
        print("No, it wasn't found... We need to improve our SEO techniques")

そして私は例外を得ました:要素は現在表示されていないため、相互作用しない可能性があります。ブラウザを待つことは解決策ではありません(スリープメソッドを長時間作成してもまだ機能しないため)。これはhttps://splinter.readthedocs.org/en/latest/#sample-codeに示されているサンプルコードですが、私にとってはうまくいきません

4

1 に答える 1

0

要素が非表示になるのを待ちたい場合は、wait 関数を使用できます。

    wait = WebDriverWait(self.driver, 30)
    wait.until(EC.invisibility_of_element_located((By.XX, "something")))
于 2015-09-23T07:14:31.727 に答える