Showing uo below error message after running the pytest code.
Traceback (most recent call last):
File "C:\Eclipse\eclipse\plugins\
main()
File "C:\Eclipse\eclipse\plugins\
return pytest.main(argv)
AttributeError: module 'pytest' has no attribute 'main'
Python version: 3.7.4
Pytest Version: 5.4.1
code:
def test_first():
path="C:\\Users\\lenova\\Desktop\\chromedriver.exe"
driver=webdriver.Chrome(executable_path=path) #from where need to execute the path #
# driver=webdriver.Chrome()
driver.get("https:\\www.clubfactory.com\\")
driver.implicitly_wait(10) # It will wait till the browser and the url is loaded. Take the time is sec#
driver.maximize_window()
time.sleep(3) #import time package to check the browser is completely opened#
driver.quit()
Instructor
09914040666 Replied on 02/04/2020
Hey,
Please make sure you make the following checks:
1. The test runner is py.test while running the test.
2. The location of the driver is properly given.
3. The package name and module name starts with test.
4. While creating package there is a file named '__init__.py' is not modified and is lying in the same package.
5. Run the test case as Python Unit-test
Still if the issue is coming for main, delete the package and recreate it
I am getting error even though I dont have any of above conditions. when I add new key word it starts to dispaly error. Also Test case stops, and no report is generated. There is some other reasons?
Instructor
09914040666 Replied on 19/05/2020
Hey,
The error who are facing can be result of different version of pytest. Please try using older version of pytest by unistalling it from cm using the command "pip uninstall pytest" and installing the older version again and try running the code.