jeya

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="[email protected]"
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

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

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

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.

Where Next?

Popular Backend topics Top

Jsdr3398
I’m trying to create a router where everything is in a collection of routes (similar to how I do my routes in expressjs). But it doesn’t ...
New
Jsdr3398
Are there any databases that require no setup (can be shipped in a small zip together with the project)?
New
joshi
Hey everybody! I’m working on the project that includes import of Oracle data to PostgreSQL. That data comes as Oracle export (expdp) fi...
New
GermaVinsmoke
Reading Programming Elixir 1.6 book, I’ve completed part 1 of the book. Now I’m thinking of reading Elixir in Action. What do you all sug...
New
Jsdr3398
I’ve been working on and rewriting my messaging platform several times for the past two years. With Discords new rebranding, it has reall...
New
mrmurphy
I’ve run into a situation where I’ve got a list of posts inside of a container that uses phx-update=“prepend”, and the posts on the socke...
New
Fl4m3Ph03n1x
Background I am trying to up my Functional Programming (FP) skills and one of the things that newcomers first learn in FP is the Option T...
New
Fl4m3Ph03n1x
Background I have recently been delving into more functional code. My objective right now is to get something similar to the IO Monad (in...
New
harwind
I received this error for a binary search programme in C, despite the fact that it requested for inputs and produced the right output. Th...
/c
New
pillaiindu
What is the difference between using :references and :belongs_to in the following command? bin/rails generate scaffold LineItem product:...
New

Other popular topics Top

PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New