Getting Error when running the testscripts from terminal "from PageObject.LoginPage import * E ModuleNotFoundError: No module named 'PageObject'"

17 views Asked by At

While running the scripts in terminal I am getting this error as mentioned in the question.

conftest

from selenium import webdriver
import pytest


# noinspection PyMissingOrEmptyDocstring
@pytest.fixture
def setup(request):
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://rlplus-dev.azurewebsites.net/account/login?ReturnUrl=%2F")
    request.cls.driver = driver

Page Object

# noinspection PyMissingOrEmptyDocstring,SpellCheckingInspection
class Login_Page:
    def __init__(self, driver):
        self.driver = driver
        self.username_field_xpath = "//input[@id='UserName']"
        self.password_field_xpath = "//input[@id='Password']"
        self.submit_btn_xpath = "//input[@value='Login']"
        self.wrongcredentialsmsg = "//li[normalize-space()='You have entered an invalid username or password']"

    def username(self, username):
        self.driver.find_element("xpath", self.username_field_xpath).send_keys(username)

    def password(self, password):
        self.driver.find_element("xpath", self.password_field_xpath).send_keys(password)

    def submitbtn(self):
        self.driver.find_element("xpath", self.submit_btn_xpath).click()

    def wrongcredentialsmsg(self):
        return self.driver.find_element("xpath", self.wrongcredentialsmsg).text

Test Case Script

import pytest
from PageObject.LoginPage import *
from PageObject.Dashboard import *


@pytest.mark.usefixtures("setup")
class TestLogin:
    driver = None

    def test_log001(self):
        lg = Login_Page(self.driver)
        db = DashboardPage(self.driver)
        lg.username("DJB")
        lg.password("djb@123DJB")
        lg.submitbtn()
        if 'Welcome' in db.check_login_success:
            assert True, "Login Successful"
        else:
            assert False, "Login not successful.Test Case Failed"

Now if I am running in the terminal screenshot Attached

What is wrong here I do not understand. Please help me.I just want to run it in terminal. I have already executed the scripts manually by running it on pycharm it is working fine. Only in the terminal i a getting this error.

0

There are 0 answers