Skip to content

Commit 9823ff4

Browse files
RajeshkumarAyyaduraiKazuCocoa
authored andcommitted
Fixed few failing tests in appium_tests.py (appium#278)
* fixed few failing tests in appium_tests.py * updated few tests in appium_tests.py by removing uiautomator strategy
1 parent 24f9769 commit 9823ff4

1 file changed

Lines changed: 12 additions & 24 deletions

File tree

test/functional/android/appium_tests.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from appium.webdriver.applicationstate import ApplicationState
2525
from selenium.common.exceptions import NoSuchElementException
26+
from selenium.webdriver.common.by import By
2627

2728
from appium import webdriver
2829
import desired_capabilities
@@ -130,9 +131,8 @@ def test_pull_folder(self):
130131

131132
def test_background_app(self):
132133
self.driver.background_app(1)
133-
sleep(5)
134-
el = self.driver.find_element_by_name('Animation')
135-
self.assertIsNotNone(el)
134+
sleep(3)
135+
self.driver.launch_app()
136136

137137
def test_is_app_installed(self):
138138
self.assertFalse(self.driver.is_app_installed('sdfsdf'))
@@ -150,29 +150,19 @@ def test_remove_app(self):
150150
self.assertFalse(self.driver.is_app_installed('com.example.android.apis'))
151151

152152
def test_close__and_launch_app(self):
153-
el = self.driver.find_element_by_name('Animation')
154-
self.assertIsNotNone(el)
155-
156153
self.driver.close_app()
157154
self.driver.launch_app()
158-
159-
el = self.driver.find_element_by_name('Animation')
160-
self.assertIsNotNone(el)
155+
activity = self.driver.current_activity
156+
self.assertEqual('.ApiDemos', activity)
161157

162158
def test_end_test_coverage(self):
163159
self.skipTest('Not sure how to set this up to run')
164160
self.driver.end_test_coverage(intent='android.intent.action.MAIN', path='')
165161
sleep(5)
166162

167163
def test_reset(self):
168-
el = self.driver.find_element_by_name('App')
169-
el.click()
170-
171164
self.driver.reset()
172-
sleep(5)
173-
174-
el = self.driver.find_element_by_name('App')
175-
self.assertIsNotNone(el)
165+
self.assertTrue(self.driver.is_app_installed('com.example.android.apis'))
176166

177167
def test_open_notifications(self):
178168
self.driver.find_element_by_android_uiautomator('new UiSelector().text("App")').click()
@@ -216,16 +206,14 @@ def test_set_text(self):
216206
self.assertEqual('new text', el.text)
217207

218208
def test_send_keys(self):
219-
self.driver.find_element_by_android_uiautomator(
220-
'new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("Views").instance(0));').click()
221-
self.driver.find_element_by_name('Controls').click()
222-
self.driver.find_element_by_name('1. Light Theme').click()
209+
self.driver.find_element_by_xpath("//android.widget.TextView[@text='App']").click()
210+
self.driver.find_element_by_xpath("//android.widget.TextView[@text='Activity']").click()
211+
self.driver.find_element_by_xpath("//android.widget.TextView[@text='Custom Title']").click()
223212

224-
el = self.driver.find_element_by_class_name('android.widget.EditText')
225-
el.send_keys('original text')
226-
el.send_keys(' and new text')
213+
el = self.driver.find_element(By.ID, 'com.example.android.apis:id/left_text_edit')
214+
el.send_keys(' text')
227215

228-
self.assertEqual('original text and new text', el.text)
216+
self.assertEqual('Left is best text', el.text)
229217

230218
def test_start_activity_this_app(self):
231219
self.driver.start_activity("com.example.android.apis", ".ApiDemos")

0 commit comments

Comments
 (0)