1

Something is really happening and i couldnt resolve for a day almost

Examples are below: Trying a simple method calling from one class to another class to figure out the problem as i have experienced the notorious problem this morning as well... so have tried a simple method calling checks... Two Class: HomePageAlone OnDemand

HomePageAlone - defined a test "def test_E_Access(self):" calls method in OnDemand i got the below error.

Code as follows:

HomePageAlone

from sikuli import *
from OnDemand import *
import OnDemand

class homePage(unittest.TestCase):

 def setUp(self):
  print("Test")   


 def test_E_Access(self):
  callMethod = OnDemand()
  callMethod.calc() # Line#15


suite = unittest.TestSuite()
suite.addTest(homePage('test_E_Access'))
unittest.TextTestRunner(verbosity=2).run(suite)

OnDemand

from sikuli import *

class OnDemand(object):

    def setUp(self):
        print("setup")


    def calc(self):
        print ("This is calling")

Log Message

======================================================================

ERROR: test_E_Access (main.homePage)

Traceback (most recent call last): File "C:\DOCUME~1\Senthil.S\LOCALS~1\Temp\sikuli-6018543662740221054.py", line 15, in test_E_Access callMethod.calc(self) # Line#15 AttributeError: 'OnDemand' object has no attribute 'calc'


Ran 1 test in 0.016s

FAILED (errors=1)

Another Try : i tried to use as the below snippet as your suggested - it always throws AttributeError: 'OnDemandPopular' object has no attribute 'calc'

import OnDemandPopular ondemand = OnDemandPopular.OnDemandPopular() ondemand.calc()

Please help


1 Answer 1

0

You should import OnDemand class from OnDemand module;

from OnDemand import OnDemand

HomePageAlone

import unittest
from OnDemand import OnDemand

class homePage(unittest.TestCase):

 def setUp(self):
  print("Test")   

 def test_E_Access(self):
  callMethod = OnDemand()
  callMethod.calc() # Line#15


suite = unittest.TestSuite()
suite.addTest(homePage('test_E_Access'))
unittest.TextTestRunner(verbosity=2).run(suite)

OnDemand

class OnDemand(object):

    def setUp(self):
        print("setup")

    def calc(self):
        print ("This is calling")

The Output is ;

This is calling
test_E_Access (HomePageAlone.homePage) ... ok

Test
This is calling
----------------------------------------------------------------------

Ran 1 test in 0.000s

OK
Test
This is calling
Sign up to request clarification or add additional context in comments.

3 Comments

What is the difference between Module and class? Class has methods and trying to access a method on the class by importing and defining an object. Do you mean a module can have multiple classes?? Please help.
In essence; Module includes classes, you must google it!
And also, if the answer is true you should close the question; click to set this answer as your accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.