Python save_屏幕截图无法在for循环中正常工作

Python save_屏幕截图无法在for循环中正常工作,python,selenium,phantomjs,Python,Selenium,Phantomjs,在本次测试中,我计划先点击“用户”,然后点击“编辑”,再点击“更改邮件”,测试这些步骤是否正常工作,同时在每个步骤后保存截图。但PhantomJS的save_截图似乎无法正常工作。例如,单击“用户”后的屏幕截图与单击“更改电子邮件”后的屏幕截图相同。很乱 medium_timeout = Data.medium_timeout #click multiple buttons #i = 0 for steps in buttonData: if steps == "wait":

在本次测试中,我计划先点击“用户”,然后点击“编辑”,再点击“更改邮件”,测试这些步骤是否正常工作,同时在每个步骤后保存截图。但PhantomJS的save_截图似乎无法正常工作。例如,单击“用户”后的屏幕截图与单击“更改电子邮件”后的屏幕截图相同。很乱

medium_timeout = Data.medium_timeout

#click multiple buttons
#i = 0
for steps in buttonData:
    if steps == "wait":
        time.sleep(2)
    elif steps == "back":
        driver.back()
    else:
        try:
            #wait for element to show up
            WebDriverWait(driver, medium_timeout).until(EC.presence_of_element_located((By.XPATH, steps)))
            WebDriverWait(driver, medium_timeout).until(EC.visibility_of_element_located((By.XPATH, steps)))

            #crashpicturename = "before" + "error" + str(i) + ".png"
            #driver.save_screenshot(crashpicturename)
        except TimeoutException:
            logging.debug(str(datetime.datetime.now()) + " TimeoutException: Unable to locate " + steps)
            return driver
        #Input some data where necessary
        if steps == "//input[@id = 'fulfill']":
            driver.find_element_by_xpath("//div[@id= 'orderItemsContainer']//input").send_keys(str(randint(10000, 99999)))
        logging.debug(str(datetime.datetime.now()) + " Clicking on " + steps)
        try:
            driver.find_element_by_xpath(steps).click()
            logging.debug(str(datetime.datetime.now()) + " after Clicking on " + steps)

            crashpicturename = "after" + "error" + str(i) + ".png"
            driver.save_screenshot(crashpicturename)
            i += 1

        except Exception as e:
            logging.debug(str(datetime.datetime.now()) + format(e))
            time.sleep(10)
            driver.find_element_by_xpath(steps).click()


return driver