Beispiel #1
0
 def test_xpath_with_square_brackets_add(self):
     object_1 = Xpath("//div[@id='timezone']")
     object_2 = Xpath(
         "//span[@class='btn btn-default form-control ui-select-toggle']")
     add_result = object_1 + object_2
     assert add_result.xpath == "//div[@id='timezone']//span[@class='btn btn-default form-control ui-select-toggle']", \
         "Addition result of {} and {} is {} instead of " \
         "//div[@id='timezone']//span[@class='btn btn-default form-control ui-select-toggle']".format(
             object_1, object_2, add_result)
Beispiel #2
0
 def test_equal(self):
     assert self.object_1 == Xpath(
         "//div"), '"self.object_1 == Xpath("//div")" is False'
Beispiel #3
0
 def test_failure_format_object(self):
     assert Xpath("//div[class='{}']").format('ONE') != Xpath("//div[class='TWO']"), \
         '"Xpath(\'//div[class="{}"]).format(\'ONE\')" is the same object as: Xpath(\'//div[class="TWO"]\')'
Beispiel #4
0
 def setUp(self):
     self.object_1 = Xpath("//div")
     self.object_2 = Xpath("//span")
Beispiel #5
0
 def test_format_return_object(self):
     assert Xpath("//div[class='{}']").format('ONE') == Xpath("//div[class='ONE']"), \
         '"Xpath(\'//div[class="{}"]).format(\'ONE\')" is not the same object as: "Xpath(\'//div[class="ONE"]\')"'
Beispiel #6
0
 def test_format_return_type(self):
     object_1 = Xpath("//div[class='{}']").format('ONE')
     assert isinstance(
         object_1, Xpath
     ), 'Xpath.format() is not a Xpath class object. Is {} instead.'.format(
         type(object_1))
Beispiel #7
0
 def test_failure_format_kwargs_but_args_given(self):
     with pytest.raises(KeyError):
         object_1 = Xpath("//div[class='{first}']|//span[type='{second}']")
         object_1.format('not', 'kwargs')
Beispiel #8
0
 def test_too_many_args_format(self):
     object_1 = Xpath("//div[class='{}']|//span[type='{}']")
     assert str(object_1.format(
         'wrong', 'number',
         'of arguments')) == "//div[class='wrong']|//span[type='number']"
Beispiel #9
0
 def test_failure_format_args_but_kwargs_given(self):
     with pytest.raises(IndexError):
         object_1 = Xpath("//div[class='{}']|//span[type='{}']")
         object_1.format(third='wrong')
Beispiel #10
0
 def test_failure_format_kwargs(self):
     with pytest.raises(KeyError):
         object_1 = Xpath("//div[class='{first}']|//span[type='{second}']")
         object_1.format(third='wrong')
Beispiel #11
0
 def test_kwargs_format_return(self):
     object_1 = Xpath("//div[class='{first}']|//span[type='{second}']")
     expected_string = "//div[class='ONE']|//span[type='Two']"
     assert str(object_1.format(first='ONE', second='Two')) == expected_string, \
         'object_1.format(\'One\', \'Two\') is not {}, but instead {}'.format(
             expected_string, object_1.format(first='ONE', second='Two'))
Beispiel #12
0
 def test_kwarg_format_return(self):
     object_1 = Xpath("//div[class='{it}']")
     expected_string = "//div[class='ONE']"
     assert str(object_1.format(it='ONE')) == expected_string, \
         'object_1.format(it=\'One\') is not {}, but instead {}'.format(expected_string, object_1.format(it='ONE'))
Beispiel #13
0
 def test_double_quote_change_to_single_quote(self):
     object_1 = Xpath('//div[@class="not"]')
     assert object_1 == "//div[@class='not']"
Beispiel #14
0
 def test_equal_two_xpath(self):
     object_2 = Xpath("//div")
     assert self.object_1 == object_2, 'Xpath("{}") is not equal to Xpath("{}")'.format(
         self.object_1, object_2)