python - 部分截图未存储在 html 报告中
问题描述
我可以将屏幕截图保存到指定文件夹;但是在构建 HTML 报告时。使用目录路径时不保存部分截图。这是一些代码:
if "Users/Therapists" in name:
print "Hello type: Link in Users / Therapists"
xpath_expression = "//*[contains(text(), 'Setup')]/parent::a"
elems = driver.find_elements_by_xpath(xpath_expression)
if elems:
hover = ActionChains(driver).move_to_element(elems[0])
hover.perform()
time.sleep(5)
print "Hello Link User/Therapist before the elems loop taking screenshot here"
driver.save_screenshot('C:/Users/xxxxx/Documents/QA/Auto/Temp/xxxxx/screenshots/file_2.png')
driver.save_screenshot(test_dir_path + name + "-pass.png")
xpath_expression = "//*[contains(text(), '" + name + "')]/parent::a"
elems = driver.find_elements_by_xpath(xpath_expression)
print "Hello Link User/Therapist before the elems loop"
if elems:
for elm in elems:
print "Hello Link User/Therapist in the elems loop"
#driver.save_screenshot(test_dir_path + name + "-beforeclick-pass.png")
#time.sleep(5)
elm.click()
time.sleep(5)
driver.save_screenshot(test_dir_path + name + "-pass.png")
driver.save_screenshot('C:/Users/xxxxxxxxx/Documents/QA/Auto/Temp/xxxxxx/screenshots/file_3.png')
results_d[name]["status"] = "success"
results_d[name]["screenshot"] = test_dir_path + name + "-pass.png"
return results_d
def build_html_report(results_d,report_number):
destination_folder_root = "reports/" + str(report_number) + ""
os.mkdir(destination_folder_root)
js_source = "report_template/js"
css_source = "report_template/css"
screenshot_Source = "screenshots/" + str(report_number)
destination_folder_css = destination_folder_root + "/css"
destination_folder_js = destination_folder_root + "/js"
destination_folder_images = destination_folder_root + "/screenshots/" + str(report_number)
解决方案
推荐阅读
- python - 对 Pandas df 中具有最不同值的值进行排序
- reactjs - 为什么使用 immer 的初始值没有变化?
- docker - Docker 容器无法通过 VPN 进行通信
- react-native - 多个叠加层在本机 iOS 中不起作用
- laravel - 干预图像在一张下调整不同图片的大小
- amazon-web-services - 将 docker 映像推送到 aws ecr 不会提供基本的身份验证凭据
- list - 当用户在飞镖中输入索引时搜索列表
- sql - 如果它们存储为字符变化,我如何在 Postgres 上减去两次?
- algorithm - 找不到组匹配算法
- snowflake-cloud-data-platform - 将带有 nextval 的新列添加到现有的 SNOWFLAKE 数据库表