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

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
Kurisu
Hello and happy new year! I would like to buy a Ruby On Rails ebook for learning purpose. What would be the ROR equivalent of “Programm...
New
jaimeiniesta
I maintain a project that lists hundreds of thousands of web pages, and I’d like to show a screenshot for each web page. There are alread...
New
osbre
Hello everyone I’m trying to implement a “magic link” or “one-time login link” functionality I wonder what a secure way to implement it...
New
sona11
I’m having a difficulty. I want to modify an attribute’s data type from String to Array. { “id”: “trn:tarb:tradingpartner:uuid:00000...
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
Fl4m3Ph03n1x
Background I have a module that uses TypedStruct to create structs. This is the code: defmodule Shared.Data.Authorization do @moduledo...
New
Sumityadav
Hello all, I am new to learning Java Programming and want to learn java from scratch. I was writing a Java program to get the first and l...
New
Fl4m3Ph03n1x
Background I have a phoenix application in Windows 11. Unfortunately for me, I cannot compile the application because of a dependency err...
New
ogoldberg
Any recommendations on good resources for learning Elixir, Phoenix, and Ash?
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
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
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
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
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New