0

This test case checks the error that can occur during login functionality

from selenium import webdriver
import unittest
class LoginCheck(unittest.TestCase):


def setUp(self):
  self.driver = webdriver.Chrome()


def login_error_check(self):
  browser = self.driver
  browser.get('https://www.saucedemo.com/')
  browser.maximize_window()
  usr = browser.find_element_by_id('user-name')
  password = browser.find_element_by_id('password')
  button = browser.find_element_by_xpath('//input[@value="LOGIN"]')
  print('Hello')
  usr.send_keys('standard_user')
  password.send_keys('password')
  button.click()

def tearDown(self):
    self.driver.quit()

if __name__ == '__main__':
    unittest.main()

I am getting below message

Ran 0 tests in 0.000s
OK
repl process died unexpectedly

was expecting that it will be success but couldn't see anything. I'm learning selenium.

0

2 Answers 2

0

test ran by prefixing the 'test' to the method

Sign up to request clarification or add additional context in comments.

2 Comments

Is this an answer to your question? If not, please delete it.
@James Z, have renamed the method from 'login_error_check' to 'test_login_error_check'. It worked for me.
0
from selenium import webdriver
import unittest
class LoginCheck(unittest.TestCase):


def setUp(self):
  self.driver = webdriver.Chrome()


def test_login_error_check(self):
  browser = self.driver
  browser.get('https://www.saucedemo.com/')
  browser.maximize_window()
  usr = browser.find_element_by_id('user-name')
  password = browser.find_element_by_id('password')
  button = browser.find_element_by_xpath('//input[@value="LOGIN"]')
  print('Hello')
  usr.send_keys('standard_user')
  password.send_keys('password')
  button.click()

def tearDown(self):
    self.driver.quit()

if __name__ == '__main__':
    unittest.main()

This will work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.