Hello @afwang
Thanks a lot for helping me in setting up Appium..
I am running this python code:
import os
import unittest
from appium import webdriver
from time import sleep
class ChessAndroidTests(unittest.TestCase):
"Class to run tests against the Chess Free app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4.2'
desired_caps['deviceName'] = 'karthikphone1'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = '/home/karthik/appiumworkspace/tests/uk.co.aifactory.chessfree.apk'
desired_caps['appPackage'] = 'uk.co.aifactory.chessfree'
desired_caps['appActivity'] = '.ChessFreeActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def test_single_player_mode1(self):
"Test the Single Player mode launches correctly"
element = self.driver.find_element_by_name("PLAY!")
element.click()
self.driver.find_element_by_name("Continue...").click()
self.driver.find_element_by_name("Single Player").click()
def tearDown(self):
"Tear down the test"
self.driver.quit()
#---START OF SCRIPT
if _ name _ == '_ main _':
suite = unittest.TestLoader().loadTestsFromTestCase(ChessAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)
I have connected my device to the notebook..
I get this error output
karthik@dkarnik2-Vostro-3558:~/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python$ python android_chess.py
test_single_player_mode1 (main.ChessAndroidTests)
Test the Single Player mode launches correctly ... ERROR
======================================================================
ERROR: test_single_player_mode1 (main.ChessAndroidTests)
Test the Single Player mode launches correctly
Traceback (most recent call last):
File "android_chess.py", line 25, in test_single_player_mode1
self.driver.find_element_by_name("Continue...").click()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 330, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/appium/webdriver/errorhandler.py", line 29, in check_response
raise wde
NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
Ran 1 test in 13.961s
FAILED (errors=1)
karthik@dkarnik2-Vostro-3558:~/appiumworkspace/appium-1.4.13/submodules/sample-code/examples/python$
Here are the screenshots of the app :
It first successfully clicks on "PLAY!" button, and in the next page it was supposed to click on "Continue..." button.
Am not able to understand, why its giving me error message..!!! (An element could not be located on the page using the given search parameters.)
While Button named "Continue..." is actually present in the app..
Is it trying to find button in the first page itself ??
Help me again..