import unittest from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By class TestScenarioA(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.base_url = "http://localhost:3000" self.title_xpath = "//li[last()][contains(concat(' ',normalize-space(@class),' '),' media ')]/div/h5" def is_element_exist(self, selector, element): try: self.driver.find_element(by=selector, value=element) except NoSuchElementException as e: return False return True def test_B_1(self): driver = self.driver driver.get(self.base_url) self.assertFalse(self.is_element_exist(By.XPATH, self.title_xpath)) def tearDown(self): self.driver.close() if __name__ == '__main__': unittest.main()