Use Sikuli to run selemium script

Asked by Lane

OS: Win7 , python27, jython2.5.3b1,sikuli1.0rc3

I use java to run selenium-server.jar

I use selemium-ide to recorder script and save as python language for RC

ttt.py
###################################
from selenium import selenium
import unittest, time, re

class ttt(unittest.TestCase):
    def setUp(self):
        self.verificationErrors = []
        self.selenium = selenium("localhost", 4444, "*chrome", "http://www.google.com.tw/")
        self.selenium.start()

    def test_ttt(self):
        sel = self.selenium
        sel.open("/")
        sel.type("id=lst-ib", "1234")
        sel.click("name=btnK")
        try: self.failUnless(sel.is_text_present(u"123(1234)"))
        except AssertionError, e: self.verificationErrors.append(str(e))

        print("Pass")

    def tearDown(self):
        self.selenium.stop()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()
###################################

If use sikuli to run ttt.py, it's work fine.

I use other py to call ttt.py, it's error
other py file is use command: ttt.ttt(unittest.TestCase)

Error message:
TypeError: getattr():attribute name must be string

Command type error? how to call ttt.py ?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

how do you "call" from other py?

paste code.

Revision history for this message
Lane (nkc24nkc24) said :
#2

main.py
###################################
import ttt
class main:
  def test(self):
      ttt.ttt(unittest.TestCase)
###################################

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

main.py
###################################
import ttt
import unittest

suite = unittest.TestLoader().loadTestsFromTestCase(ttt.ttt) # loads your test class
unittest.TextTestRunner(verbosity=2).run(suite) # runs it

###################################

see faq 1804

Revision history for this message
Lane (nkc24nkc24) said :
#4

Thanks for your help~~

Revision history for this message
Lane (nkc24nkc24) said :
#5

Thanks RaiMan, that solved my question.