File indexing completed on 2024-05-12 05:04:11
0001 #!/usr/bin/env python3 0002 0003 # SPDX-License-Identifier: BSD-3-Clause 0004 # SPDX-FileCopyrightText: 2023 Rishi Kumar <rsi.dev17@gmail.com> 0005 0006 import sys 0007 import unittest 0008 from appium import webdriver 0009 from appium.options.common.base import AppiumOptions 0010 from appium.webdriver.common.appiumby import AppiumBy 0011 from appium.options.common.app_option import AppOption 0012 from selenium.webdriver.common.keys import Keys 0013 0014 0015 class ATSPIOptions(AppiumOptions, AppOption): 0016 pass 0017 0018 0019 class SearchBoxTest(unittest.TestCase): 0020 0021 def setUp(self): 0022 options = ATSPIOptions() 0023 options.app = tokodon_offline_path 0024 self.driver = webdriver.Remote( 0025 command_executor='http://127.0.0.1:4723', 0026 options=options) 0027 0028 0029 def tearDown(self): 0030 self.driver.get_screenshot_as_file("failed_test_shot_{}.png".format(self.id())) 0031 self.driver.quit() 0032 0033 0034 def test_search_and_app(self): 0035 searchElement = self.driver.find_element(by=AppiumBy.NAME, value="Search") 0036 searchFocused = searchElement.get_attribute('focused') 0037 self.assertTrue(searchFocused) 0038 searchElement.click() 0039 searchElement.send_keys("myquery") 0040 searchElement.send_keys(Keys.ENTER) 0041 0042 self.assertTrue(self.driver.find_element(by=AppiumBy.NAME, value="People") or self.driver.find_element(by=AppiumBy.NAME, value="Post") or self.driver.find_element(by=AppiumBy.NAME, value="Hashtags") ) 0043 0044 0045 0046 if __name__ == '__main__': 0047 tokodon_offline_path = sys.argv[1] 0048 sys.argv.pop() 0049 unittest.main()