Skip to content

Latest commit

 

History

History
97 lines (73 loc) · 2.59 KB

DOCUMENTATION.md

File metadata and controls

97 lines (73 loc) · 2.59 KB

Pytholenium Documentation

Selection types and usage

pytholenium relies on finding element by selenium selectors and attribute selectors. It starts with a Selenium selectors search, and with those WebElements output, it applies the Attribute selectors search.

Selenium selectors:

  • id
  • name
  • xpath
  • link_text
  • partial_link_text
  • tag_name
  • class_name
  • css_selector

Each one refers to the actual Selenium selectors

Attribute selectors:

  • text
  • tag_name_attribute
  • ... and any attribute you want to specify

pytholenium only allows 0 or 1 Selenium selector, and any amount of Attribute selectors

Examples

  • Using only Selenium
<div id="hello_there">Hey there!</div>
params = {"id": "hello_there"}
print (pl.get(driver, params).text)
  • Using only Attribute
<sometag>How are you?</sometag>
params = {"tag_name_attribute": "sometag"}
print(pl.get(driver=driver, params=params).text)
  • Using mixed selection
<div name="multiple" old_city="barcelona" new_city="madrid">You might see this is a strange html</div>
<div name="multiple" old_city="barcelona" new_city="london">But don't worry</div>
<div name="multiple" old_city="barcelona" new_city="buenos aires">Everything is under control ;)</div>
params = {"name": "multiple", "old_city": "barcelona", "new_city": "london"}
print(pl.get(driver=driver, params=params).text)
  • Special Attribute selectors

tag_name_attribute is a "special" Attribute selector, since tag_name is a Selenium's selector, but you might want to search for it as an attribute. In case of text Attribute selector, it will compare the element's text

<div>Oh man, you are really reading this documentation!</div>
<sometag>I'm glad :)</sometag>
#By text
params = {"text": "Oh man, you are really reading this documentation!"}
print(pl.get(driver=driver, params=params).text)

#By tag_name_attribute
params = {"tag_name_attribute": "sometag"}
print(pl.get(driver=driver, params=params).text)

Methods

Available methods are:

  • get
  • gets
  • wait
  • do
  • wait_do

You can see each docstring documentation by doing

from pytholenium import pytholenium as pl
help(pl)

Need more examples?

Please check our unit test and the html file. Each test is related to a html element with certain conditions, so you can see how pytholenium works.