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="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

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.

Popular Backend topics Top

PragmaticBookshelf
Go is a modern programming language that combines the reliability of compiled languages with the ease of use and flexibility of dynamic t...
New
PragmaticBookshelf
Learning Clojure involves much more than just learning the mechanics. To really get Clojure you need to understand the ideas underlying i...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
New
Kurisu
Following on an old discussion I started on Elixir Forum here, I finally made my mind to learn Ruby on Rails in addition to Elixir/Phoen...
New
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
mafinar
I did not add this to a “this weekend I’ll learn” like my few other journals as I am decided on using this in the long term. Last I work...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1017 16885 373
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
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
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New