0

I am facing an issue in retrieving a browser driver issue as logs says collecting ... collected 1 item

====== WebDriver manager ======
Could not get version for google-chrome with the any command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
Current google-chrome version is UNKNOWN
Get LATEST chromedriver version for UNKNOWN google-chrome
Driver [C:\Users\diksh\.wdm\drivers\chromedriver\win32\97.0.4692.71\chromedriver.exe] found in cache

test_MainPage.py:None (test_MainPage.py)
test_MainPage.py:5: in <module>
    class TestMainPage:
..\..\venv\lib\site-packages\_pytest\fixtures.py:1203: in __call__
    raise ValueError("class fixtures not supported (maybe in the future)")
E   ValueError: class fixtures not supported (maybe in the future)

collected 0 items / 1 error

=================================== ERRORS ====================================
______________________ ERROR collecting test_MainPage.py ______________________
test_MainPage.py:5: in <module>
    class TestMainPage:
..\..\venv\lib\site-packages\_pytest\fixtures.py:1203: in __call__
    raise ValueError("class fixtures not supported (maybe in the future)")
E   ValueError: class fixtures not supported (maybe in the future)
------------------------------- Captured stderr -------------------------------


====== WebDriver manager ======
Could not get version for google-chrome with the any command: reg query "HKEY_CURRENT_USER\Software\Google\Chrome\BLBeacon" /v version
Current google-chrome version is UNKNOWN
Get LATEST chromedriver version for UNKNOWN google-chrome
Driver [C:\Users\diksh\.wdm\drivers\chromedriver\win32\97.0.4692.71\chromedriver.exe] found in cache
============================== warnings summary ===============================
..\Locator_Declaration_test\test_Browser_Locators.py:11
  C:\Users\diksh\PycharmProjects\Automation_Project\Test_Suit\Locator_Declaration_test\test_Browser_Locators.py:11: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
    dchrome= webdriver.Chrome(ChromeDriverManager().install())

The code that I'm trying to execute is;

import pytest
from Test_Suit.Locator_Declaration_test.test_Browser_Locators import TestBrowserLocator as BL

@pytest.fixture(scope="session")
class TestMainPage:

    def driver_get(request):
        web_driver = BL.dchrome
        print(web_driver)
        session = request.node
        for item in session.items:
            cls=item.getparent(pytest.Class)
            setattr(cls.obj,"driver",web_driver)
        yield
        web_driver.close()

    url = BL.url
    username = BL.username_textbox_xpath
    password = BL.password_textbox_xpath
    login = BL.login_button_xpath

    Logout = BL.Signout_button_xpath
    MyAccount = BL.MyAccount_link

@pytest.mark.usefixtures("driver_init")
class BaseTest:
    pass

    @pytest.mark.usefixtures("BaseTest")
    def test_Browser(self):  # This is a method which will run once before the execution starts

        # driver = self.driver
        print("The method starts")
        self.driver.maximize_window()

I need your help to understand where I'm going wrong? Why this piece of code wouldn't execute?

1
  • Are you sure you can define a class as a fixture? The error says you can't. Also, we don't see driver_init fixture anywhere but where it is used. I think the docs can help you docs.pytest.org/en/latest/how-to/… and docs.pytest.org/en/latest/explanation/… I also don't understand how you use BaseTest fixture, that might be an incorrect usage as well. And that block od code starting with url = BL.url line seems to be not part of any method, but a part of a class, that might be wrong.
    – pavelsaman
    Jan 21 at 13:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.