Skip to content

Commit b37d334

Browse files
author
yennj12
committed
update
1 parent 9269070 commit b37d334

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

mobly/browser_test.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,39 @@ def test_open_browser(self):
1616
self.dut.adb.shell('am start -a android.intent.action.VIEW -d "http://www.google.com"')
1717
time.sleep(5) # Wait for the page to load
1818

19+
self.dut.adb.shell('am start -a android.intent.action.VIEW -d "http://www.github.com"')
20+
time.sleep(5) # Wait for the page to load
21+
self.search_github()
22+
23+
24+
def search_github(self):
25+
print(">>> Searching for 'github' on Google")
26+
27+
# Focus on the search bar: tapping on the search bar (coordinates need to be accurate)
28+
self.dut.adb.shell('input tap 540 160') # Coordinates for the Google search bar (adjust as needed)
29+
time.sleep(1) # Give it some time to focus
30+
31+
# Simulate typing 'github' into the search box
32+
self.dut.adb.shell('input text "github"')
33+
time.sleep(1) # Allow time for the text to be typed in
34+
35+
# Simulate pressing the search button (Enter key)
36+
self.dut.adb.shell('input keyevent 66') # Enter key (search)
37+
time.sleep(3) # Wait for the search results to load
38+
39+
def test_click_first_result(self):
40+
print(">>> Clicking the first search result for GitHub")
41+
# Simulate clicking the first result (coordinates of the first result)
42+
# Coordinates for first result can be different based on your device or screen resolution,
43+
# you may need to adjust it based on your test device's screen size.
44+
self.dut.adb.shell('input tap 540 960') # Example coordinates for tapping on the first result
45+
time.sleep(5) # Wait for the page to load
46+
1947
def test_exit_browser(self):
2048
print(">>> Exiting browser")
2149
# Exit the browser using the back button (back to home screen or app list)
2250
self.dut.adb.shell('input keyevent 4') # Press back button
23-
time.sleep(2) # Ensure the transition happens
51+
time.sleep(1) # Ensure the transition happens
2452

2553
def teardown_class(self):
2654
# This will run after all tests have finished

0 commit comments

Comments
 (0)