In [1]:
%%html
<style>
table {float:left}
</style>


Simplified Selenium Functions

For example, if you are using Selenium in your automated functional tests, instead of coding directly in Selenium like this:


In [ ]:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('https://python.org.')
download = browser.find_element_by_link_text('Downloads')
download.click()
download = browser.find_element_by_id('downloads')
ul = download.find_element_by_tag_name('ul')
lis = ul.find_elements_by_tag_name('li')

You can alternatively use Marigoso functions to help you code a little bit better like this:


In [2]:
from marigoso import Test
browser = Test().launch_browser('Firefox')
browser.get_url('https://python.org')
browser.press('Downloads')
download = browser.get_element('id=downloads')
ul = download.get_child('tag=ul')
lis = ul.get_children('tag=li')

Listed below are some of the functions provided by Marigoso and their equivalent functions in Selenium. Since Marigoso is just a layer that sits on top of Selenium, you can still use Selenium functions while taking advantage of the alternative functions provided by Marigoso.

Getting a Single Web Element from a Web Page

Marigoso Selenium
get_element("css=xxx") find_element_by_css_selector("xxx")
get_element("xpath=xxx") find_element_by_xpath("xxx")
get_element("xxx") find_element_by_link_text("xxx")
get_element("class=xxx") find_element_by_class_name("xxx")
get_element("id=xxx") find_element_by_id("xxx")
get_element("name=xxx") find_element_by_name("xxx")
get_element("plink=xxx") find_element_by_partial_link_text("xxx")
get_element("tag=xxx") find_element_by_tag_name("xxx")

Getting Multiple Web Elements from a Web Page

Marigoso Selenium
get_all("css=xxx") find_elements_by_css_selector("xxx")
get_all("xpath=xxx") find_elements_by_xpath("xxx")
get_all("xxx") find_elements_by_link_text("xxx")
get_all("class=xxx") find_elements_by_class_name("xxx")
get_all("id=xxx") find_elements_by_id("xxx")
get_all("name=xxx") find_elements_by_name("xxx")
get_all("plink=xxx") find_elements_by_partial_link_text("xxx")
get_all("tag=xxx") find_elements_by_tag_name("xxx")

Getting a Single Web Element from a given Web Element

Marigoso Selenium
element.get_child("css=xxx") element.find_element_by_css_selector("xxx")
element.get_child("xpath=xxx") element.find_element_by_xpath("xxx")
element.get_child("xxx") element.find_element_by_link_text("xxx")
element.get_child("class=xxx") element.find_element_by_class_name("xxx")
element.get_child("id=xxx") element.find_element_by_id("xxx")
element.get_child("name=xxx") element.find_element_by_name("xxx")
element.get_child("plink=xxx") element.find_element_by_partial_link_text("xxx")
element.get_child("tag=xxx") element.find_element_by_tag_name("xxx")

Getting Multiple Web Elements from a given Web Element

Marigoso Selenium
element.get_children("css=xxx") element.find_elements_by_css_selector("xxx")
element.get_children("xpath=xxx") element.find_elements_by_xpath("xxx")
element.get_children("xxx") element.find_elements_by_link_text("xxx")
element.get_children("class=xxx") element.find_elements_by_class_name("xxx")
element.get_children("id=xxx") element.find_elements_by_id("xxx")
element.get_children("name=xxx") element.find_elements_by_name("xxx")
element.get_children("plink=xxx") element.find_elements_by_partial_link_text("xxx")
element.get_children("tag=xxx") element.find_elements_by_tag_name("xxx")

In [ ]: