Does Python have anything Like Capybara/Cucumber?

后端 未结 7 1171
星月不相逢
星月不相逢 2021-01-29 23:48

Ruby has this great abstraction layer on top of Selenium called Capybara, which you can use do functional/acceptance/integration testing. It also has another library called Cuc

7条回答
  •  一整个雨季
    2021-01-30 00:08

    The OP asked for Python implementations of Cucumber or Capybara but as Jim Stewart pointed out in his answer, Cucumber and Capybara are very different things. Since the title of the question is about Capybara, that's what I will answer.

    I am one of the developers of a commercial Selenium wrapper called Helium. Like Capybara, it offers a very high-level API for web automation. For example, here is a script that updates your Facebook status:

    from helium.api import *
    start_chrome("facebook.com")
    write(your_fb_email, into="Email or Phone")
    write(your_fb_password, into="Password")
    click("Log In")
    write("Test", into="Update Status")
    click("Post")
    

    Calls to Helium can freely be mixed with calls to Selenium. Eg. we could extend the above script by:

    # get_driver() returns the WebDriver created by start_chrome() above.
    chrome = get_driver()
    chrome.find_element_by_id('btnG').click()
    

提交回复
热议问题