Getting "Empty Suite" while runing pytest #10366
-
Hi Community :) Thanks for your precious help ! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @SarraGomyCode, Please post:
|
Beta Was this translation helpful? Give feedback.
-
Hi, yes here you are : import time
import pytest
from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
@pytest.mark.usefixtures("SetUp")
class SearchFlightDemo :
def test_search_flight_demo (self):
#browser for flight's search
self.driver.find_element(By.XPATH, "//a[@title='One Way']").click()
departure_destination = self.driver.find_element(By.ID,"BE_flight_origin_city")
departure_destination.click()
departure_destination.send_keys("New Delhi")
departure_destination.send_keys(Keys.ENTER)
arrival_destination = self.driver.find_element(By.ID,"BE_flight_arrival_city")
arrival_destination.click()
arrival_destination.send_keys("New")
arrival_destination.send_keys(Keys.ENTER)
arrival_destination_list = self.driver.find_elements(By.XPATH,"//div[@class='viewport']//div[1]//li")
# (len(arrival_destination_list))
for result in arrival_destination_list :
print(result.text)
if "New York (JFK)" in result.text :
result.click()
time.sleep(4)
break
self.wait.until(EC.element_to_be_clickable((By.ID,"BE_flight_origin_date"))).click()
all_dates = self.wait.until(EC.element_to_be_clickable((By.XPATH,"//div[@id='monthWrapper']//tbody//td[@class!='inActiveTD']"))).find_elements(By.XPATH,"//div[@id='monthWrapper']//tbody//td[@class!='inActiveTD']")
for date in all_dates :
if date.get_attribute('title') == "Wednesday, 12 October 2022":
print(date.text)
date.click()
time.sleep(4)
break
self.wait.until(EC.element_to_be_clickable((By.ID,"BE_flight_flsearch_btn"))).click()
#driver.find_element(By.XPATH,"//div[@class='ripple-parent search-height demo-icon icon-go']//input[@id='BE_flight_flsearch_btn']").click()
# driver.find_element(By.XPATH, "//div[@class='filter-heading pr sticky full-width']//label[2]").click()
# all_stops = wait.until(EC.presence_of_all_elements_located(By.XPATH,"//div[@class='stop-det bdr-btm pb-5 v-aligm-t text-left']//tbody//tr//td[1]"))
all_stops = self.driver.find_elements(By.XPATH,
"//*[contains(text(), '1 Stop') or contains(text(), '2 Stop(s)') or contains(text(), 'Non Stop') ] ")
print(len(all_stops))
for stop1 in all_stops:
assert stop1.text == "1 Stop"
print("test OK") Output result : ============================= test session starts ============================= ============================ no tests ran in 0.45s ============================ Process finished with exit code 5 Empty suite |
Beta Was this translation helpful? Give feedback.
-
@SarraGomyCode, try to rename |
Beta Was this translation helpful? Give feedback.
@SarraGomyCode, try to rename
SearchFlightDemo
toTestSearchFlightDemo
. See: https://docs.pytest.org/en/stable/explanation/goodpractices.html#conventions-for-python-test-discovery