2

Could someone helping me to understand why the following code is executed, but no action is performed?

Returned code is 0 but browser is not opened or no action is performed.

it is worth to mention that setUp method has been configured in the same way in other modules and it works correctly. Please check at the end the response.


import unittest
from Init_load import set_up
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
class HomeTest(unittest.TestCase):
 def setUp(self):
 con = set_up.Connect()
 self.driver = con.setUp()
 #self.link_list = ["Home", "flights", "Destinations", "CONTACT", "SIGN-ON", "REGISTER", "SUPPORT", "Hotels", \
 # "Car Rentals", "Cruises"]
 self.home = (By.LINK_TEXT, "Home")
 self.flights = (By.LINK_TEXT, "flights")
 self.destinations = (By.LINK_TEXT, "Destinations")
 self.contact = (By.LINK_TEXT, "CONTACT")
 self.sign_on = (By.LINK_TEXT, "SIGN-ON")
 self.register = (By.LINK_TEXT, "REGISTER")
 self.support = (By.LINK_TEXT, "SUPPORT")
 self.hotels = (By.LINK_TEXT, "Hotels")
 self.car_rentals = (By.LINK_TEXT, "Car Rentals")
 self.cruises = (By.LINK_TEXT, "Cruises")
 def test_homeLink(self):
 self._elementWait(By.LINK_TEXT, "home")
 self.driver.find_element(*self.home).click()
 def test_flight_link(self):
 self._elementWait(By.LINK_TEXT, "flights")
 self.driver.find_element(*self.home).click()
 def test_destinations_link(self):
 self._elementWait(By.LINK_TEXT, "flights")
 self.driver.find_element(*self.destinations).click()
 def test_contact_link(self):
 self._elementWait(By.LINK_TEXT, "flights")
 self.driver.find_element(*self.contact).click()
 def test_signOn_link(self):
 self._elementWait(By.LINK_TEXT, "SIGN-ON")
 self.driver.find_element(*self.contact).click()
 def test_register_link(self):
 self._elementWait(By.LINK_TEXT, "REGISTER")
 self.driver.find_element(*self.register).click()
 def test_support_link(self):
 self._elementWait(By.LINK_TEXT, "SUPPORT")
 self.driver.find_element(*self.support).click()
 def test_hotels_link(self):
 self._elementWait(By.LINK_TEXT, "hotels")
 self.driver.find_element(*self.hotels).click()
 def test_carRentals_link(self):
 self._elementWait(By.LINK_TEXT, "Car Rentals")
 self.driver.find_element(*self.car_rentals).click()
 def test_cruises_link(self):
 self._elementWait(By.LINK_TEXT, "cruises")
 self.driver.find_element(*self.cruises).click()
 def _elementWait(self,how, what):
 WebDriverWait(self.driver, 12).until(expected_conditions.element_to_be_clickable((how, what)), \
 "Element not loaded yet")
 def tearDown(self):
 self.driver.quit()

This is the response:

/home/osboxes/PycharmProjects/Automation/venv/bin/python /home/osboxes/PycharmProjects/Automation/unit_test/home_test.py
Process finished with exit code 0

Other scripts with exactly the same setUp() function are executed correctly but no this one. Ive tried a lot of options, but nothing works

undetected Selenium
194k44 gold badges304 silver badges387 bronze badges
asked Jun 13, 2018 at 23:03
2
  • you need to pass it to a test runner. you can do: python -m unittest and it will dkiscover your tests Commented Jun 14, 2018 at 0:59
  • Can you update the question with the file containing Connect() Commented Jun 14, 2018 at 8:14

1 Answer 1

4

Are you calling your unittest with:

if __name__ == '__main__':
 unittest.main()

If you do not, then you are just defining the test, not actually executing anything.

answered Jun 14, 2018 at 0:20
Sign up to request clarification or add additional context in comments.

1 Comment

Nice catch. This should have been the accepted answer.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.