Update test_workflow.py

This commit is contained in:
Leon 2023-06-03 02:30:50 +02:00 committed by GitHub
parent dc7dd12f05
commit f2d1273dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 18 deletions

View File

@ -13,11 +13,23 @@ from pathlib import Path
logging.basicConfig(level=10)
logger = logging.getLogger('test')
def main():
####
# this block is a dirty helper since
# in the action runner devices serveral chrome versions exists
# and i need to ensure it takes the one which is installed
# by the task.
####
for k,v in os.environ.items():
logger.info("%s = %s" % (k,v))
logger.info('==== END ENV ==== ')
tmp = Path('/tmp').resolve()
for item in tmp.rglob('**'):
logger.info('found %s ' % item)
@ -33,37 +45,51 @@ def main():
browser_executable_path = str(item / 'chrome')
break
####
# test really starts here
#3##
driver = uc.Chrome(headless=True, browser_executable_path=browser_executable_path)
logging.getLogger().setLevel(20)
driver.get('https://www.nowsecure.nl')
print(driver.current_url)
logger.info('current url %s' % driver.current_url)
try:
WebDriverWait(driver,10).until(EC.visibility_of_element_located(("css selector", "body")))
WebDriverWait(driver,10).until(EC.title_contains('moment'))
except TimeoutException:
pass
print(driver.current_url)
logger.info('current url %s' % driver.current_url)
try:
WebDriverWait(driver,10).until(EC.text_to_be_present_in_element(("css selector", "main h1"), "OH YEAH, you passed!"))
WebDriverWait(driver,10).until(EC.title_contains('nowSecure'))
except TimeoutException:
logging.getLogger().setLevel(20)
driver.reconnect()
print(driver.current_url)
logger.info('trying to save a screenshot via imgur')
else:
logger.info( "PASSED CLOUDFLARE! ")
logger.info('trying to save a screenshot via imgur')
# driver.reconnect()
driver.save_screenshot('/tmp/screenshot.png')
driver.get('https://imgur.com/upload')
driver.find_element('css selector', 'input').send_keys('/tmp/screenshot.jpg')
time.sleep(5)
logger.info('A SCREENSHOT IS SAVED ON %s' % driver.current_url)
time.sleep(5)
driver.save_screenshot('/tmp/screenshot.png')
driver.get('https://imgur.com/upload')
driver.find_element('css selector', 'input').send_keys('/tmp/screenshot.png')
time.sleep(1)
logger.info('current url %s' % driver.current_url)
time.sleep(1)
logger.info('A SCREENSHOT IS SAVED ON %s' % driver.current_url)
time.sleep(5)
driver.quit()