当前位置: 动力学知识库 > 问答 > 编程问答 >

unit testing - unbound method in unittest in python

问题描述:

This is my login file

import unittest from selenium

import webdriver

class login(unittest.TestCase):

def setUp(self):

self.driver = webdriver.Chrome()

def test_login(self):

driver = self.driver

driver = self.driver

driver.get("http://localhost:8080/iprint//#/login")

self.driver.find_element_by_name("userName").send_keys("admin")

self.driver.find_element_by_name("password").send_keys("1234")

self.driver.find_element_by_xpath("//button[@class='btn btn-primary btn-lg btn-block']").click()

This is my location printer file.

import unittest

from selenium import webdriver

from login import login

class printer(unittest.TestCase):

def setUp(self):

driver = webdriver.chrome()

def test_printer(self):

login.test_login(self)

driver = self.driver

self.driver.find_element_by_xpath("//span[@data-i18n='Masters']").click()

self.driver.find_element_by_xpath("//span[@data-i18n='Printers']").click()

if __name__ =='__main__':

unittest.main()

I am trying to avoid repeating setUp method by inheriting it from the first file. Both are in the same directory as required but I keep getting the following error:

Error Traceback (most recent call last): File

"C:\Users\Diana\Desktop\flash\Removable

Disk\PycharmProjects\testcase\Diana\printer.py", line 7, in setUp

driver = webdriver.chrome() TypeError: 'module' object is not callable

Process finished with exit code 0

please assist,thanks.

分享给朋友:
您可能感兴趣的文章:
随机阅读: