I am learning Selenium with python, so please excuse my amateur questions, I am trying to run a simple Data driven test where selenium will enter a few different names on the Name field.
The Page code is as below:
class AddClients(BasePage):
log = cl.customLogger(logging.DEBUG)
def __init__(self, driver):
super().__init__(driver)
self.driver = driver
def appy(self,name):
self.clickAddBtn()
self.enterEmpname(name)
time.sleep(2)
self.clickCancel()
I am running the tests on a different script
from pages.clients.addclient_page import AddClients
from utilities.teststatus import TestStatus
import unittest
import pytest
from ddt import ddt,data, unpack
@pytest.mark.usefixtures("oneTimeSetUp","setUp")
@ddt
class AddClientTest(unittest.TestCase):
@pytest.fixture(autouse=True)
def classSetup(self,oneTimeSetUp):
self.ac = AddClients(self.driver)
self.ts = TestStatus(self.driver)
@pytest.mark.run(order=1)
@data(("employeronefffffffffffffffffffffffffffffff"),("tester"))
@unpack
def test_adding_client(self,naming):
self.ac.appy(naming)
time.sleep(3)
But when I try to run the script it throws the error below:
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-3.0.2, py-1.4.31, pluggy-0.3.1 -- c:\program files (x86)\python35-32\python.exe
cachedir: .cache
rootdir: C:\Users\Fake\PycharmProjects\Kode, inifile:
collected 0 items / 1 errors
============================== ERRORS ===============================
____________ ERROR collecting tests/clients/addclient_test2.py ____________
c:\program files (x86)\python35-32\lib\site-packages\_pytest\python.py:209: in fget
return self._obj
E AttributeError: 'Module' object has no attribute '_obj'
During handling of the above exception, another exception occurred:
tests\clients\addclient_test2.py:11: in <module>
class AddClientTesttwo(unittest.TestCase):
c:\program files (x86)\python35-32\lib\site-packages\ddt.py:258: in ddt
add_test(cls, test_name, func, **v)
E TypeError: add_test() argument after ** must be a mapping, not str
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.32 seconds ===========================
I am running all the test on py.test. Note: the browser doesn't even launch.
@data(('emploer',''), ('tester',''))
When I add a null value to data, the browser launches and does the sign in process but then fails with:
self = <tests.clients.addclient_test2.AddClientTesttwo testMethod=test_adding_client_1___emploer____tester__>
@wraps(func)
def wrapper(self):
> return func(self, *args, **kwargs)
E TypeError: test_adding_client() takes 2 positional arguments but 3 were given
c:\program files (x86)\python35-32\lib\site-packages\ddt.py:139: TypeError