Test fails while getting URL

Dear Geeks

I am new to pytest. I am following a youtube channel. I am writing the same code.
learning to test login functionality of an ecommerce application
i have written testcase file. please have a look at it. while running the testcase i am getting error in the line self.driver.get(self.baseURL)
error messaeg

test_login.py:10 (Test_001_Login.test_homePageTitle)
self = <testCases.test_login.Test_001_Login object at 0x000001CC152D38E0>

    def test_homePageTitle(self):
        self.driver=webdriver.Chrome()
>       self.driver.get(self.baseURL)

it is blocking to move further learning as it is the first test
The original code ::

import pytest
from selenium import webdriver
from pageObjects.LoginPage import LoginPage

class Test_001_Login:
    baseURL = "https://admin-demo.nopcommerce.com/"
    username="admin@yourstore.com"
    password="admin"


    def test_homePageTitle(self):
        self.driver=webdriver.Chrome()
        self.driver.get(self.baseURL)
        actual_title=self.driver.title
        if actual_title=="Your store. Login":
            assert True
            self.driver.close()
        else:
            assert False
            self.driver.close()

    def test_Login(self):
        self.driver=webdriver.Chrome()
        self.driver.get(self.baseURL)
        self.lp=LoginPage(self.driver)
        self.lp.setUserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        actual_title=self.driver.title
        if actual_title == "Dashboard / nopCommerce administration":
            assert True
            self.driver.close()
        else:
            assert False
            self.driver.close()

Thank you guys

I’m not sure but you’ll have to struggle with this one for a few more days to figure it out. I’d look at self.driver.get. What is that? Did you print what self.baseURL is? Did you print out what’s being returned by self.driver.get()?

Try those things. You’ll need to print everything you can, and spend the time investigating why this returns something other than what you expect. It’s better to try to figure these out on your own than to run for help immediately. Spend at least two days to a week on this, and if you aren’t printing everything then you aren’t doing what you need to figure it out.

A few more things:

  1. Do you have to use a class for this?
  2. When you post more code to the forum put it inside ```.
  3. Add some spacing between your = signs. It might help you figure out what’s going on.
  4. It looks like you typed all this code in and then are trying to fix it. Try deleting this and doing it in little pieces that you run repeatedly. It’s easier than blasting a file full of code and trying to fix 100 errors.

Try that.

Thank you zed. actually self.baseURL is the input to self.driver.get. self.baseURL is hardcoded.

A free service run by Zed A. Shaw for learncodethehardway.org.