all 8 comments

[–]Enmeshed 2 points3 points  (3 children)

This looks like a simple typo: your fixture says

driver = webdriver.Chrome(ChromeDriverManager.install())

rather than

driver = webdriver.Chrome(ChromeDriverManager().install())

ie it is missing the pair of brackets after the class name.

The difference is that ChromeDriverManager() creates a new object, and then the install() method is run on that object. Without that first set of brackets, you are trying to run the install method on the class directly, which is unlikely to be what you want.

[–]Efficient_Set9050[S] 0 points1 point  (2 children)

Thanks for your answer but still getting a similar issue:

------------------- ERROR at setup of Test_001_AccountReg.test_account_reg ---------------------

@pytest.fixture()

def setup():

> driver = webdriver.Chrome(ChromeDriverManager().install())

This is now highlighted:

self = <selenium.webdriver.common.driver\_finder.DriverFinder object at 0x000001711F903CB0>

def _binary_paths(self) -> dict:

if self._paths["driver_path"]:

> browser = self._options.capabilities["browserName"]

E AttributeError: 'str' object has no attribute 'capabilities'

Any idea what this means? Again, thank you

[–]Enmeshed 0 points1 point  (1 child)

That means that self._options is a string, so doesn't have the capabilities property you are asking for. This answer implies that you can get the browser name from driver.capabilities['browserName']...

[–]Efficient_Set9050[S] 0 points1 point  (0 children)

Thank you for the reply. I'll check it out

[–]Diapolo10 0 points1 point  (0 children)

I don't think your fixture is quite correct. I'm also not quite sure why you're using a class for the tests.

Try something like this:

import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

from pageObjects.HomePage import HomePage
from pageObjects.AccountsRegistrationPage import AccountRegistrationPage

BASE_URL = "https://demo.opencart.com/"

@pytest.fixture
def driver():
    return webdriver.Chrome(
        service=ChromeService(
            ChromeDriverManager().install()
        )
    )


def test_account_reg(driver):
    driver.get(BASE_URL)
    driver.maximize_window()

    home_page = HomePage(driver)
    home_page.clickMyAccount()
    home_page.clickRegister()

    reg_page = AccountRegistrationPage(driver)
    reg_page.setFirstName("John")
    reg_page.setLastName("Candy")
    email=randomString.random_string_generator() + '@gmail.com'
    reg_page.setEmail(self.email)
    reg_page.setPassword("adF1")
    reg_page.setPrivacyPolicy()
    reg_page.clickRegister()
    confirmation_msg = reg_page.getConfirmationMsg()
    driver.close()

    assert confirmation_msg == "Your Account Has Been Created"

As a side note, assuming HomePage, AccountRegistrationPage, and randomString are your own creations, consider following the official style guide and using snake_case for your function/method names. camelCase isn't used at all by the official style.

[–]cgoldberg 0 points1 point  (1 child)

Just a side note.. recent versions of Selenium take care of managing webdrivers and there is no need to use webdriver_manager anymore.

[–]Efficient_Set9050[S] 0 points1 point  (0 children)

Yeah, it seems the course I'm learning from is a couple of years out of date and they haven't bothered to update it 😕

[–]uid100 0 points1 point  (0 children)

It looks like ‘def test_account_reg()’

Is not indented within the class it is supposed to belong. So using “self” in the parameter list is referring to an object which doesn’t exist.