Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将python selenium转换为selenium ide命令_Python_Python 2.7_Selenium_Selenium Webdriver_Selenium Ide - Fatal编程技术网

将python selenium转换为selenium ide命令

将python selenium转换为selenium ide命令,python,python-2.7,selenium,selenium-webdriver,selenium-ide,Python,Python 2.7,Selenium,Selenium Webdriver,Selenium Ide,下面是一个能够执行以下操作的python脚本: 查找所选的当前日期 选择下一个可用日期 如果当月未找到可用日期,请按“下一步”转到下个月 我的问题是,我还想包括一个selenium ide verson,仅在其中用户只需要记录他们的步骤。有没有一种方法可以将我下面的代码转换成IDE中的命令、目标和值,这样它就可以做同样的事情?若您可以按顺序提供命令、目标和值的列表,那个么将非常有用 我正在测试的网站是www.jet2.com,它是关于出发日期的 我只想在IDE中转换的原因是,将来手动测试时,

下面是一个能够执行以下操作的python脚本:

  • 查找所选的当前日期
  • 选择下一个可用日期
  • 如果当月未找到可用日期,请按“下一步”转到下个月
我的问题是,我还想包括一个selenium ide verson,仅在其中用户只需要记录他们的步骤。有没有一种方法可以将我下面的代码转换成IDE中的命令、目标和值,这样它就可以做同样的事情?若您可以按顺序提供命令、目标和值的列表,那个么将非常有用

我正在测试的网站是www.jet2.com,它是关于出发日期的

我只想在IDE中转换的原因是,将来手动测试时,我可以使用IDE回放来执行其余的测试。claendar是我遇到的唯一一个小故障,它是使用python方法解决的

# select date
datepicker = driver.find_element_by_id("departure-date-selector")
actions.move_to_element(datepicker).click().perform()

# find the calendar, month and year picker and the current date
calendar = driver.find_element_by_id("departureDateContainer")
month_picker = Select(calendar.find_element_by_class_name("ui-datepicker-month"))
year_picker = Select(calendar.find_element_by_class_name("ui-datepicker-year"))
current_date = calendar.find_element_by_class_name("ui-datepicker-current-day")

# printing out current date
month = month_picker.first_selected_option.text
year = year_picker.first_selected_option.text
print("Current date: {day} {month} {year}".format(day=current_date.text, month=month, year=year))

# see if we have an available date in this month
try:
    next_available_date = current_date.find_element_by_xpath("following::td[@data-handler='selectDay' and ancestor::div/@id='departureDateContainer']")
    print("Found an available date: {day} {month} {year}".format(day=next_available_date.text, month=month, year=year))
    next_available_date.click()
except NoSuchElementException:
# looping over until the next available date found
        while True:
# click next, if not found, select the next year
            try:
                calendar.find_element_by_class_name("ui-datepicker-next").click()
            except NoSuchElementException:
# select next year
                year = Select(calendar.find_element_by_class_name("ui-datepicker-year"))
                year.select_by_visible_text(str(int(year.first_selected_option.text) + 1))

# reporting current processed month and year
                month = Select(calendar.find_element_by_class_name("ui-datepicker-month")).first_selected_option.text
                year = Select(calendar.find_element_by_class_name("ui-datepicker-year")).first_selected_option.text
                print("Processing {month} {year}".format(month=month, year=year))

            try:
                next_available_date = calendar.find_element_by_xpath(".//td[@data-handler='selectDay']")
                print("Found an available date: {day} {month} {year}".format(day=next_available_date.text, month=month, year=year))
                next_available_date.click()
                break
            except NoSuchElementException:
                continue

我想我不可能使用纯硒IDE,但是你可以使用像 或者获取if-else、goto和loop功能
以及JavaScript类似的条件、可调用函数、错误捕捉和JSON/XML驱动的参数化。

我知道这不能回答您的问题,但是在您考虑IDE在您的长期计划中,它可能值得检查安得烈,实际上我以前看过这个页面。我想使用IDE,这样我就可以向那些不熟悉自动化的人展示一种快速入门的方法,当我们走上更高级的道路时,在使用web驱动程序之前。有些测试人员没有您看到的开发背景,但我认为Selenium的态度是WebDriver是标准的,而不是高级的方法,非开发人员应该使用许多框架或DSL中的一种。在管理过非技术测试人员之后,我想说,使用像样的DSL,他们至少可以像使用IDE一样高效。