Update test_workflow.py
This commit is contained in:
parent
dc7dd12f05
commit
f2d1273dc4
|
@ -13,11 +13,23 @@ from pathlib import Path
|
||||||
logging.basicConfig(level=10)
|
logging.basicConfig(level=10)
|
||||||
logger = logging.getLogger('test')
|
logger = logging.getLogger('test')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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():
|
for k,v in os.environ.items():
|
||||||
logger.info("%s = %s" % (k,v))
|
logger.info("%s = %s" % (k,v))
|
||||||
logger.info('==== END ENV ==== ')
|
logger.info('==== END ENV ==== ')
|
||||||
tmp = Path('/tmp').resolve()
|
tmp = Path('/tmp').resolve()
|
||||||
|
|
||||||
for item in tmp.rglob('**'):
|
for item in tmp.rglob('**'):
|
||||||
logger.info('found %s ' % item)
|
logger.info('found %s ' % item)
|
||||||
|
|
||||||
|
@ -33,34 +45,45 @@ def main():
|
||||||
browser_executable_path = str(item / 'chrome')
|
browser_executable_path = str(item / 'chrome')
|
||||||
break
|
break
|
||||||
|
|
||||||
|
####
|
||||||
|
# test really starts here
|
||||||
|
#3##
|
||||||
|
|
||||||
driver = uc.Chrome(headless=True, browser_executable_path=browser_executable_path)
|
driver = uc.Chrome(headless=True, browser_executable_path=browser_executable_path)
|
||||||
logging.getLogger().setLevel(20)
|
logging.getLogger().setLevel(20)
|
||||||
|
|
||||||
driver.get('https://www.nowsecure.nl')
|
driver.get('https://www.nowsecure.nl')
|
||||||
|
|
||||||
print(driver.current_url)
|
logger.info('current url %s' % driver.current_url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
WebDriverWait(driver,10).until(EC.visibility_of_element_located(("css selector", "body")))
|
WebDriverWait(driver,10).until(EC.title_contains('moment'))
|
||||||
except TimeoutException:
|
except TimeoutException:
|
||||||
pass
|
pass
|
||||||
print(driver.current_url)
|
|
||||||
|
|
||||||
|
logger.info('current url %s' % driver.current_url)
|
||||||
|
|
||||||
try:
|
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:
|
except TimeoutException:
|
||||||
logging.getLogger().setLevel(20)
|
logging.getLogger().setLevel(20)
|
||||||
driver.reconnect()
|
|
||||||
print(driver.current_url)
|
print(driver.current_url)
|
||||||
|
else:
|
||||||
|
logger.info( "PASSED CLOUDFLARE! ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger.info('trying to save a screenshot via imgur')
|
logger.info('trying to save a screenshot via imgur')
|
||||||
# driver.reconnect()
|
# driver.reconnect()
|
||||||
driver.save_screenshot('/tmp/screenshot.png')
|
driver.save_screenshot('/tmp/screenshot.png')
|
||||||
|
|
||||||
driver.get('https://imgur.com/upload')
|
driver.get('https://imgur.com/upload')
|
||||||
|
|
||||||
driver.find_element('css selector', 'input').send_keys('/tmp/screenshot.jpg')
|
driver.find_element('css selector', 'input').send_keys('/tmp/screenshot.png')
|
||||||
|
|
||||||
time.sleep(5)
|
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)
|
logger.info('A SCREENSHOT IS SAVED ON %s' % driver.current_url)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
@ -69,5 +92,8 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue