
jeya
Pytest: 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 = “Your store. Login
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
Most Liked

mafinar
The code you shared, are they part if a class? What does that class inherit? Usually with cases like this with pytest one should create a fixture which souls contain web driver specific functionalities.

mafinar
Ah i see you have some code that escaped the code block lol. I will try this code in a few minutes once i am in front of a laptop.

mafinar
One thing though, can you ensure that you have chrome driver installed and it’s on your path? Although in that case, you would be getting more error instead of just the error you mentioned. Something like: ... selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. ...
somewhere along the line.
Popular Backend topics










Other popular topics










Latest in Backend
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /spring
- /django
- /diversity
- /lua
- /nodejs
- /slackware
- /c
- /julia
- /neovim