improving AndroidEmulator
This commit is contained in:
@@ -107,6 +107,17 @@
|
|||||||
" @staticmethod\n",
|
" @staticmethod\n",
|
||||||
" def _start():\n",
|
" def _start():\n",
|
||||||
" os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n",
|
" os.system(\"/home/frankknoll/Android/Sdk/emulator/emulator -avd Pixel_2_API_30 -no-window &\")\n",
|
||||||
|
" AndroidEmulator._waitUntilStarted()\n",
|
||||||
|
" \n",
|
||||||
|
" @staticmethod\n",
|
||||||
|
" def _waitUntilStarted():\n",
|
||||||
|
" while not AndroidEmulator._isStarted():\n",
|
||||||
|
" time.sleep(1)\n",
|
||||||
|
"\n",
|
||||||
|
" @staticmethod\n",
|
||||||
|
" def _isStarted():\n",
|
||||||
|
" boot_completed = ! adb shell getprop sys.boot_completed\n",
|
||||||
|
" return boot_completed[0] == '1'\n",
|
||||||
"\n",
|
"\n",
|
||||||
" @staticmethod\n",
|
" @staticmethod\n",
|
||||||
" def _stop():\n",
|
" def _stop():\n",
|
||||||
@@ -149,6 +160,21 @@
|
|||||||
" return not existsElementWithId(driver, \"wordverify\")\n"
|
" return not existsElementWithId(driver, \"wordverify\")\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "da7c965a",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import time\n",
|
||||||
|
"import os.path\n",
|
||||||
|
"\n",
|
||||||
|
"def waitUntilDownloadHasFinished(file):\n",
|
||||||
|
" while not os.path.exists(file):\n",
|
||||||
|
" time.sleep(2)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
@@ -168,31 +194,8 @@
|
|||||||
" textInCaptchaImage = AndroidEmulator.run(lambda: getTextInCaptchaImage(captchaImageFile))\n",
|
" textInCaptchaImage = AndroidEmulator.run(lambda: getTextInCaptchaImage(captchaImageFile))\n",
|
||||||
" display('textInCaptchaImage: ', textInCaptchaImage)\n",
|
" display('textInCaptchaImage: ', textInCaptchaImage)\n",
|
||||||
" driver.find_element(By.ID, \"verificationCode\").send_keys(textInCaptchaImage)\n",
|
" driver.find_element(By.ID, \"verificationCode\").send_keys(textInCaptchaImage)\n",
|
||||||
" driver.find_element(By.CSS_SELECTOR, '[name=\"downloadbut\"]').click()"
|
" driver.find_element(By.CSS_SELECTOR, '[name=\"downloadbut\"]').click()\n",
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "aef4d1c3",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"import time\n",
|
|
||||||
"import os.path\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"def waitUntilDownloadHasFinished(file):\n",
|
|
||||||
" while not os.path.exists(file):\n",
|
|
||||||
" time.sleep(2)"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "741ec545",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"def downloadFile(file, driver, maxTries):\n",
|
"def downloadFile(file, driver, maxTries):\n",
|
||||||
" captchaImageFile = 'captchaImage.jpeg'\n",
|
" captchaImageFile = 'captchaImage.jpeg'\n",
|
||||||
" tryNum = 1\n",
|
" tryNum = 1\n",
|
||||||
@@ -205,35 +208,28 @@
|
|||||||
" waitUntilDownloadHasFinished(file)\n",
|
" waitUntilDownloadHasFinished(file)\n",
|
||||||
" return True\n",
|
" return True\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" return False\n"
|
" return False\n",
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "8eef224c",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"downloadDir = \"/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch/src/VAERS/tmp\"\n",
|
|
||||||
"file2Download = '2022VAERSData.zip'\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"driver = getWebDriver(downloadDir, isHeadless = False)\n",
|
"def downloadVAERSFile(file):\n",
|
||||||
"driver.get('https://vaers.hhs.gov/eSubDownload/index.jsp?fn=' + file2Download)\n",
|
" downloadDir = \"/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch/src/VAERS/tmp\"\n",
|
||||||
"downloadFile(\n",
|
" driver = getWebDriver(downloadDir, isHeadless = False)\n",
|
||||||
" file = downloadDir + \"/\" + file2Download,\n",
|
" driver.get('https://vaers.hhs.gov/eSubDownload/index.jsp?fn=' + file)\n",
|
||||||
" driver = driver,\n",
|
" isFileDownloaded = downloadFile(\n",
|
||||||
" maxTries = 2)"
|
" file = downloadDir + \"/\" + file,\n",
|
||||||
|
" driver = driver,\n",
|
||||||
|
" maxTries = 2)\n",
|
||||||
|
" driver.quit()\n",
|
||||||
|
" return isFileDownloaded"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "380bcf32",
|
"id": "9a9e4d1e",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"driver.quit()"
|
"downloadVAERSFile('2022VAERSData.zip')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user