Reputation: 11
I am new to web automation and python so please understand my problem may be trivial to you all. I am trying to use Appium to test an app and to press a button on the screen. Using my minimum knowledge i have I created a test case below that is meant to do that but I get an error 'dict' object has no attribute 'driver'
from appium import webdriver
import time
def setUp():
self = dict(
platformName = "Android",
platformVersion = "10",
deviceName= "name",
app= "C:\\AppiumProjects\\app-debug.apk",
automationName= "UiAutomator2",
appActivity = ".activities.SplashScreenActivity",
appPackage = 'genericsurveyapp2',
noReset = True,
)
self.driver = webdriver.Remote('http://localhost:4723/wd/hub',self)
time.sleep(2)
time.sleep(2)
self.el = self.driver.find_element_by_id("idacceptButton")
time.sleep(2)
self.el.click
setUp()
Upvotes: 0
Views: 772
Reputation: 1083
I think you're getting confused by naming your dictionary of config options self.
When working in a class self
allows you to reference variables and methods of the class using "dot notation". However with a dictionary "dot notation" lets you access variables and methods of the dictionary class, not the contents of the dictionary.
You basically have 3 options for how to solve this:
self['driver'] = webdriver.Remote('http://localhost:4723/wd/hub',self)
self['el'] = self['driver'].find_element_by_id("idacceptButton")
self['el'].click()
driver
and el
as variables in the local context of the function. If you intend to throw away the config, driver, and page element after setup, this is the solution I'd go with.driver = webdriver.Remote('http://localhost:4723/wd/hub',self)
el = driver.find_element_by_id("idacceptButton")
el.click()
Upvotes: 1