我在这里和那里读过,我们现在应该使用Selenium 2(WebDriver,如果我的理解是正确的).我不是在谈论非常容易使用的Selenium IDE.
我已经阅读了Selenium网站上的文档(由于Selenium 2不稳定,因此声称不完整,这很好).我的问题是:我无法从Selenium开始.
我的意思是,如上所述,我已下载它,启动它.我在这里和那里找到了样品测试用例.
但是你如何(使用Selenium/WebDriver):
也许我错过了关于这一切如何运作的文档?如果可以的话,你能指出我的意思吗?
作为旁注,我是OS X用户,尽管我认为这不是问题.
谢谢.
我希望我的selenium IDE测试用例像下面的步骤一样运行,以便自动选择日期:
有人可以告诉我,因为我是硒新手,如何为上述例子做这件事吗?我的所有脚本目前都可以打开日历.
下面是我设法收到的与上面截图匹配的html:
//Months drop down
<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">
<option value="2" selected="selected">Mar
</option><option value="3">Apr</option>
<option value="4">May</option>
<option value="5">Jun</option>
<option value="6">Jul</option>
<option value="7">Aug</option>
<option value="8">Sep</option>
<option value="9">Oct</option>
</select>
//Years drop down
<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">
<option value="2016" selected="selected">2016</option>
</select>
<table class="ui-datepicker-calendar">
//days labels
<thead>
<tr>
<th scope="col"><span title="Monday">Mo</span></th>
<th scope="col"><span title="Tuesday">Tu</span></th>
<th scope="col"><span title="Wednesday">We</span></th>
<th scope="col"><span title="Thursday">Th</span></th>
<th scope="col"><span title="Friday">Fr</span></th>
<th scope="col" class="ui-datepicker-week-end"><span title="Saturday">Sa</span></th>
<th scope="col" class="ui-datepicker-week-end"><span title="Sunday">Su</span></th>
</tr>
</thead>
<tbody>
//dates
<tr>
<td class=" ui-datepicker-other-month …Run Code Online (Sandbox Code Playgroud) 我是selenium的新手,我正尝试使用Selenium IDE(2.9.0)创建第一个单击记录脚本作为基本脚本,然后使用Selenium WebDriver(2.48.0)对其进行完善。
我记录了一个工作脚本(请参阅本问题末尾的附件),并将其导出为“ python 2 / unittest / WebDriver”。但是,源代码清楚地表明它存在一些问题(带有令人不适的“ ERROR”语句的注释行):
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class Test1(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://ironspider.ca/"
self.verificationErrors = []
self.accept_next_alert = True
def test_1(self):
driver = self.driver
driver.get(self.base_url + "/frames/frames_example1/advanced.htm")
# ERROR: Caught exception [ERROR: Unsupported command [selectFrame | content | …Run Code Online (Sandbox Code Playgroud) 下面我有一个能够执行以下操作的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} …Run Code Online (Sandbox Code Playgroud) selenium ×4
python ×2
automation ×1
html ×1
javascript ×1
python-2.7 ×1
selenium-ide ×1
webdriver ×1