I am working with Selenium 3.4.0 with Python 3.6.1. I have written a script following the Python documentation through unittest module which is a built-in Python based on Java’s JUnit using geckodriver 0.16.1 and Mozilla Firefox 57.0 on Windows 8 Pro machine, 64 bit OS, x-64 processor. In my test method test_search_in_python_org() I have the following lines which works well:
def test_search_in_python_org(self):
driver = self.driver
driver.get("http://www.python.org")
self.assertIn("Python", driver.title)
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
When I am asserting the "page title" I am using: self.assertIn("Python", driver.title)
But, when I am asserting a string (my assumption), within the page source I am using: assert "No results found." not in driver.page_source
My question is what are the factors/conditions which decides whether I should use self.assertIn or simply assert?
Any suggestions or pointers will be helpful.