一些屏幕截图未存储在html报告中

时间:2018-12-17 20:04:36

标签: python selenium-webdriver

我可以将屏幕截图保存到指定的文件夹;但是在生成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)

0 个答案:

没有答案