Skip to content

[🐛 Bug]: Unable to access methods of WebDriver class when the WebDriver instance is passed to test class from conftest.py #14340

Open
@Shipinpk

Description

@Shipinpk

What happened?

Not getting any suggestion regarding the webdriver in test class. ( Both in pycharm and vscode ) The code is working fine but its very difficult to type all the code manually without giving the suggestions.

How can we reproduce the issue?

Created conftest.py

code :
import pytest
from selenium import webdriver

@pytest.fixture(scope="class", autouse=True)
def driverInit(request):
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.implicitly_wait(10)
    driver.get("https://opensource-demo.orangehrmlive.com/web/index.php/auth/login")
    request.cls.driver = driver
    yield
    driver.close


Test class file

Code :

import pytest
from selenium.webdriver.common.by import By

@pytest.mark.usefixtures("driverInit")
class TestOne:
 
    def test_loginScenario(self):
        self.driver.find_element(By.XPATH, "//input[@name='username']").send_keys("Admin")
        self.driver.find_element(By.XPATH, "//input[@name='password']").send_keys("admin")
        self.driver.

here after the self.driver. no suggestion?

Details : 
pycharm community edition Version: 2024.1.4
python version : Python 3.12.4
pytest version : pytest 8.3.2

Relevant log output

No suggestions for webdriver is showing in test class level

Operating System

windows

Selenium version

4.23.0

What are the browser(s) and version(s) where you see this issue?

Chrome and firefox

What are the browser driver(s) and version(s) where you see this issue?

Chrome Version 127.0.6533.89 (Official Build) (64-bit)

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython BindingsI-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions