samedi 29 août 2020

can yo help me on: AttributeError: type object 'PagesTesting' has no attribute 'test_011_employee'

I'm trying to run the test_011_employee for each different code "M00007", "M00009", "M00011" in python so that I don't have to re do all the code for every different code I need and i'm getting AttributeError: type object 'PagesTesting' has no attribute 'test_011_employee', can you kindly help me solve the error ?

complete error:

Ran 1 test in 0.003s

FAILED (errors=1)

Error
Traceback (most recent call last):
  File "C:\Users\RonaldCamilleri\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 60, in testPartExecutor
    yield
  File "C:\Users\RonaldCamilleri\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "C:\Users\RonaldCamilleri\AppData\Local\Programs\Python\Python38-32\lib\unittest\case.py", line 633, in _callTestMethod
    method()
  File "C:\Users\RonaldCamilleri\AppData\Local\Programs\Python\Python38-32\lib\unittest\loader.py", line 34, in testFailure
    raise self._exception
  File "C:\Users\RonaldCamilleri\AppData\Local\Programs\Python\Python38-32\lib\unittest\loader.py", line 169, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: type object 'LoginTest' has no attribute 'test_011_employee'


Process finished with exit code 1

Assertion failed

Assertion failed

Assertion failed

Assertion failed

Assertion failed

Assertion failed

Assertion failed

Assertion failed
@ddt
class PagesTesting(unittest.TestCase):

    @classmethod
    def setUp(cls):
        # create a new Chrome session
        opts = Options()
        opts.binary_location = "path to chrome.exe"
        cls.driver = webdriver.Chrome(options=opts, executable_path='path to chromedriver.exe')
        unittest.TestLoader.sortTestMethodsUsing = None
        cls.driver.implicitly_wait(60)
        cls.driver.maximize_window()

        # navigate to the application home page
        cls.driver.get("website address")
        wait = WebDriverWait(cls.driver, 60)

    def tearDown(self):
        for method, error in self._outcome.errors:
            if error:
                test_method_name = self._testMethodName
                self.driver.save_screenshot(
                    "screenshotname.png"
                    % test_method_name)

        # Close the browser window
        self.driver.close()

    @data("M00007", "M00009", "M00011")
    def test_011_employee(self, code):

        wait = WebDriverWait(webdriver, 60)
        
        Login.test_001_Login() #this call is used to log into the website

        employeesbutton = wait.until(
            ec.visibility_of_element_located((By.XPATH, '/html/body/form/div[1]/div/div/nav/ul/li[2]/a/span[1]')))
        
        employeesbutton.click()
        
        employeedetailsbutton = wait.until(
            ec.visibility_of_element_located((By.XPATH, '/html/body/form/div[1]/div/div/nav/ul/li[2]/ul/li[1]/a/span')))
        
        employeedetailsbutton.click()

        frame0 = wait.until(
            ec.visibility_of_element_located((By.XPATH, '/html/body/form/div[1]/main/div/div[2]/div[2]/iframe')))
        
        self.driver.switch_to.frame(frame0)

        self.driver.find_element_by_xpath('/html/body/form/div[3]/div[6]/div/p/button[4]').click()  # click clear button
        sleep(5)
        
        self.driver.find_element_by_xpath('/html/body/form/div[3]/div[2]/div[2]/div/input').clear()  # clear input box
        sleep(5)

        employeeid = wait.until(
            ec.visibility_of_element_located(
                (By.XPATH, '/html/body/form/div[3]/div[2]/div[2]/div/input')))  # locate input box
        
        employeeid.click()
        employeeid.send_keys(code)
        sleep(5)
        employeeid.send_keys(Keys.RETURN)

Aucun commentaire:

Enregistrer un commentaire