selenium locate by tagname code example
Example 1: tags in selenium
Tags are keywords helps us group our tests and create running
structure for our testing suite.
WE can run specific scenarios, or exclude specific scenarios.
---- We have 3 keyword in Cucumber for to use tags:
1- OR: if we want to run all the listed tests we use or
2- AND: we want the scenario/feature to have all of the given tags to be ran.
3- NOT: basically if we want to exclude any test with a specific @tag given,
we provide it after "not" keyword. Those scenarios will not be ran.
Example 2: find elements in selenium
#In Python
#Let's say that we want to locate the h1 tag in this HTML:
#<html>
# <head>
# ... some stuff
# </head>
# <body>
# <h1 class="someclass" id="greatID">Super title</h1>
# </body>
#</html>
h1 = driver.find_element_by_name('h1')
h1 = driver.find_element_by_class_name('someclass')
h1 = driver.find_element_by_xpath('//h1')
h1 = driver.find_element_by_id('greatID')