Update test_workflow.py
This commit is contained in:
parent
e10ac0382b
commit
c53876a83a
|
@ -1,20 +1,17 @@
|
||||||
import logging
|
# coding: utf-8
|
||||||
import os
|
|
||||||
import time
|
|
||||||
logging.basicConfig(level=10)
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
import selenium.webdriver.support.expected_conditions as EC
|
import time
|
||||||
|
import logging
|
||||||
from selenium.webdriver.support.wait import WebDriverWait
|
from selenium.webdriver.support.wait import WebDriverWait
|
||||||
from pathlib import Path
|
import selenium.webdriver.support.expected_conditions as EC
|
||||||
|
from selenium.common.exceptions import TimeoutException
|
||||||
import undetected_chromedriver as uc
|
import undetected_chromedriver as uc
|
||||||
|
|
||||||
|
logging.basicConfig(level=10)
|
||||||
|
logger = logging.getLogger('test')
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
# due to the randomneess of the chrome install path on the runner when running action, i have to find it manufally
|
for k,v in os.environ.items():
|
||||||
|
|
||||||
for k,v in os.environ.items():
|
|
||||||
logger.info("%s = %s" % (k,v))
|
logger.info("%s = %s" % (k,v))
|
||||||
tmp = Path('/tmp').resolve()
|
tmp = Path('/tmp').resolve()
|
||||||
|
|
||||||
|
@ -28,13 +25,48 @@ def main():
|
||||||
path_list.insert(0, str(item))
|
path_list.insert(0, str(item))
|
||||||
os.environ['PATH'] = os.pathsep.join(path_list)
|
os.environ['PATH'] = os.pathsep.join(path_list)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
driver = uc.Chrome(headless=True)
|
||||||
|
driver.get('https://www.nowsecure.nl')
|
||||||
|
|
||||||
|
print(driver.current_url)
|
||||||
|
|
||||||
|
try:
|
||||||
|
WebDriverWait(driver,10).until(EC.visibility_of_element_located(("css selector", "body")))
|
||||||
|
except TimeoutException:
|
||||||
|
pass
|
||||||
|
print(driver.current_url)
|
||||||
|
try:
|
||||||
|
WebDriverWait(driver,10).until(EC.text_to_be_present_in_element(("css selector", "main h1"), "OH YEAH, you passed!"))
|
||||||
|
except TimeoutError:
|
||||||
|
logging.getLogger().setLevel(20)
|
||||||
|
print(driver.current_url)
|
||||||
|
logger.info('trying to save a screenshot via imgur')
|
||||||
|
# driver.reconnect()
|
||||||
|
driver.save_screenshot('c:/tmp/screenshot.jpg')
|
||||||
|
driver.get('https://imgur.com/upload')
|
||||||
|
driver.find_element('css selector', 'input').send_keys('c:/tmp/screenshot.jpg')
|
||||||
|
|
||||||
|
time.sleep(2)
|
||||||
|
logger.info('A SCREENSHOT IS SAVED ON %s' % driver.current_url)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
driver = uc.Chrome(headless=True)
|
driver.quit()
|
||||||
driver.get("https://nowsecure.nl")
|
|
||||||
WebDriverWait(driver, 15).until(
|
|
||||||
EC.text_to_be_present_in_element(("css selector", "main h1"), "OH YEAH, you passed!"))
|
|
||||||
driver.quit()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
# def main():
|
||||||
|
|
||||||
|
# # due to the randomneess of the chrome install path on the runner when running action, i have to find it manufally
|
||||||
|
|
||||||
|
|
||||||
|
# time.sleep(5)
|
||||||
|
# driver = uc.Chrome(headless=True)
|
||||||
|
# driver.get("https://nowsecure.nl")
|
||||||
|
# WebDriverWait(driver, 15).until(
|
||||||
|
# EC.text_to_be_present_in_element(("css selector", "main h1"), "OH YEAH, you passed!"))
|
||||||
|
# driver.quit()
|
||||||
|
|
||||||
|
|
||||||
|
# if __name__ == "__main__":
|
||||||
|
# main()
|
||||||
|
|
Loading…
Reference in New Issue