Skip to content

Commit 9269070

Browse files
author
yennj12
committed
add
1 parent 980e43b commit 9269070

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

mobly/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ python3 open_setting_test.py -c sample_config.yml
9494
python3 take_photo_test.py -c sample_config.yml
9595

9696

97+
#-----------------------
98+
# TEST 7
99+
#-----------------------
100+
101+
python3 browser_test.py -c sample_config.yml
102+
103+
97104
#-----------------------
98105
# TEST ?
99106
#-----------------------

mobly/browser_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from mobly import base_test
2+
from mobly import test_runner
3+
from mobly.controllers import android_device
4+
import time
5+
6+
class BrowserTest(base_test.BaseTestClass):
7+
def setup_class(self):
8+
# This will run before any test method starts
9+
print(">>> BrowserTest start")
10+
self.ads = self.register_controller(android_device)
11+
self.dut = self.ads[0]
12+
13+
def test_open_browser(self):
14+
print(">>> Opening browser and visiting www.google.com")
15+
# Launch browser and visit www.google.com using adb shell
16+
self.dut.adb.shell('am start -a android.intent.action.VIEW -d "http://www.google.com"')
17+
time.sleep(5) # Wait for the page to load
18+
19+
def test_exit_browser(self):
20+
print(">>> Exiting browser")
21+
# Exit the browser using the back button (back to home screen or app list)
22+
self.dut.adb.shell('input keyevent 4') # Press back button
23+
time.sleep(2) # Ensure the transition happens
24+
25+
def teardown_class(self):
26+
# This will run after all tests have finished
27+
print(">>> BrowserTest completed")
28+
29+
if __name__ == '__main__':
30+
test_runner.main()

0 commit comments

Comments
 (0)