eclipse - Python desired capabilities error -
after setting desired capabilities (desired_caps
), getting error script. error is
if desired_capabilities none:
^ indentationerror: unexpected indent
here code:
import unittest selenium import webdriver appium import webdriver appium import webdriver selenium.webdriver.common import desired_caps webdriver import webdriver remote class cnnendtoend(unittest.testcase): desired_caps = {} desired_caps['platformname'] = 'android' desired_caps['platformversion'] = '6.0.1' desired_caps['devicename'] = 'samsung' #desired_caps['app'] = path('../../../apps/selendroid-test-app.apk') desired_caps['apppackage'] = 'com.android.vending' desired_caps['appactivity'] = '.assetbrowseractivity' print desired_caps self.driver = webdriver.remote('http://localhost:4723/wd/hub', desired_caps) def testacnninstallandlaunch(self): print "**************************" print "********app install*******" print "**************************" print "here---------" #appid = "com.cnn.mobile.android.phone" if (self.driver.is_app_installed("com.cnn.mobile.android.phone")): print "-----app installed" if __name__ == '__main__': suite = unittest.testloader().loadtestsfromtestcase(cnnendtoend) unittest.texttestrunner(verbosity=2).run(suite)
full error message:
traceback (most recent call last): file "/users/manusimply/.p2/pool/plugins/org.python.pydev_5.8.0.201706061859/pysrc/_pydev_runfiles/pydev_runfiles.py", line 468, in __get_module_from_str mod = __import__(modname) file "/users/manusimply/desktop/eclipse/cnn_poc/cnn_new.py", line 2, in <module> appium import webdriver file "/users/manusimply/desktop/eclipse/appium-python-client-0.2/appium/webdriver/__init__.py", line 19, in <module> webdriver import webdriver remote file "/users/manusimply/desktop/eclipse/appium-python-client-0.2/appium/webdriver/webdriver.py", line 15, in <module> selenium import webdriver file "/users/manusimply/desktop/eclipse/selenium-3.4.3/selenium/webdriver/__init__.py", line 18, in <module> .firefox.webdriver import webdriver firefox # noqa file "/users/manusimply/desktop/eclipse/selenium-3.4.3/selenium/webdriver/firefox/webdriver.py", line 34, in <module> selenium.webdriver.remote.webdriver import webdriver remotewebdriver file "/users/manusimply/desktop/eclipse/selenium-3.4.3/selenium/webdriver/remote/webdriver.py", line 79 if desired_capabilities none: ^ indentationerror: unexpected indent error: module: cnn_new not imported (file: /users/manusimply/desktop/eclipse/cnn_poc/cnn_new.py).
you should use desiredcapabilities object, not list of capabilities want implement. make life bit easier you. initialize variable shown below, add you're capabilities variable.
from selenium.webdriver.common.desired_capabilities import desiredcapabilities desired_caps = desiredcapabilities.chrome
see link more details on initializing webdriver in python: http://selenium-python.readthedocs.io/getting-started.html
also make sure using correct naming conventions each capability. there list of capabilities , names here: https://github.com/seleniumhq/selenium/wiki/desiredcapabilities
hopefully helps out :)
Comments
Post a Comment