How to generate html test report in selenium while triggering my test with Django and Plain html as my test script is running but generating nothing?

Viewed 12

This is my viws.py file

# Create your views here.

def test_home(request):
 return render(request, 'Acode.html')

def end_home(request):
 return render(request, 'After.html')   

@csrf_exempt
def run_home(request): 
  if request.method == 'POST':

    objs = json.loads(request.body)

    for val in objs:
        if val=='1.1':
            l= login()
            l.setUpClass()
            l.test_menu()
            l.tearDownClass()
        
        if val=='1.2':
            l= create_course_test()
            l.setUpClass()
            l.test_admin_Page()
            l.tearDownClass()

        if val=='1.3':
            l= create_course_test_draft()
            l.setUpClass()
            l.test_admin_Page()
            l.tearDownClass()    

    content = '<p>dummy content</p>'
    return HttpResponse(content)


// Test.Login_Menu_Test file:

@classmethod
 def setUpClass(cls):
    const = 'https://trainingroot.z29.web.core.windows.net/'
    cls.driver.get(const)
    cls.driver.maximize_window()

 def test_menu(self):
    self.const = 'https://trainingroot.z29.web.core.windows.net/'
    currentList = self.driver.find_elements(By.TAG_NAME, 'a').sort()
    previousList = Project_urls.urls.sort()

    WebDriverWait(self.driver, 10).until(
            EC.presence_of_element_located(
                (By.XPATH, '//*[@id="single-spa-application:@Training"]/div/div/div[1]/p')))

    if currentList == previousList:
        self.driver.get(self.const + 'home')
        self.driver.get(self.const + 'course category')
        self.driver.get(self.const + 'calender')
        self.driver.get(self.const + 'FAQ')
        self.driver.get(self.const + 'expert')
        self.driver.get(self.const + 'requesttraining')
        self.driver.get(self.const + 'myachievements')
    else:
        print('Some thing is missing')

@classmethod
def tearDownClass(cls):
    cls.driver.close()
    cls.driver.quit()
    print('Test Completed')

if name == 'main': unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='../Selenium/Reports'))

// my code is generating test reports only when I trigger it from the terminal but I want to trigger it with the Django application... // If I put the last statement inside the teardown function, then it doesn't start and may be the root cause of the problem

0 Answers
Related