我的应用程序有以下代码片段:
<form id="frmDepartmentCreation" name="frmDepartmentCreation" method="post"
action="">
<table class="formStyle_1" border="0" cellpadding="0" cellspacing="10"
width="100%">
<tr>
<td> </td>
<td align="left"><label class="formBtn_1">
<input id="Submit" name="Submit" value="Submit" type="submit"
onclick="return val()"/></label>
<input type="hidden" name="hdnbutton" id="hdnbutton" value=""/>
</td>
</tr>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
考虑到上面的代码,"提交"按钮的xpath是什么?
我正在使用Selenium进行自动化.我正在使用DefaultSelenium
课程,在我们的应用程序中我有一个下拉菜单.我想从这个下拉列表中获得一个值.
最初,我使用selenium IDE编写脚本,它给了我以下代码:
selenium.select("id=skuOptionSIZE1c4b403", "label=8");
Run Code Online (Sandbox Code Playgroud)
但是当我开始用代码(Java)编写时,Eclipse会抛出一个错误,而我仍然能够看到id
页面上的下拉列表:
Exception in thread "main" com.thoughtworks.selenium.SeleniumException: ERROR: Element id=skuOptionSIZE1cd7bfd not found
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我如何从下拉中获取价值?
我想获取数据并在没有标签的情况下组织它.它看起来像这样
<table class="SpecTable">
<col width="40%" />
<col width="60%" />
<tr>
<td class="LightRowHead">Optical Zoom:</td>
<td class="LightRow">15x</td>
</tr>
<tr>
<td class="DarkRowHead">Digital Zoom:</td>
<td class="DarkRow">6x</td>
</tr>
<tr>
<td class="LightRowHead">Battery Type:</td>
<td class="LightRow">Alkaline</td>
</tr>
<tr>
<td class="DarkRowHead">Resolution Megapixels:</td>
<td class="DarkRow">14 MP</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我希望能够提取所有信息字符串,以便我可以存储在纯文本文件中:
光学变焦:15倍数码变焦:6倍电池类型:碱性分辨率百万像素:14 MP
public static void main(String[] args) {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override", "some UA string");
WebDriver driver = new FirefoxDriver(profile);
String Url = "http://www.walmart.com/ip/Generic-14-MP-X400-BK/19863348";
driver.get(Url);
List<WebElement> resultsDiv = driver.findElements(By.xpath("//table[contains (@class,'SpecTable')//td"));
System.out.println(resultsDiv.size());
for (int i=0; i<resultsDiv.size(); i++) {
System.out.println(i+1 …
Run Code Online (Sandbox Code Playgroud) 是否有必要下载Selenium IDE来执行Selenium示例?
我正在尝试在Java上执行Selenium应用程序.请帮助我完成步骤和示例示例...
我想知道是什么的好处DefaultSelenium
了SeleneseTestCase
类?
什么DefaultSelenium
是好的?
什么SeleneseTestCase
是好的?
Java Doc说:创建一个PriorityQueue,其默认初始容量(11)根据其自然顺序对其元素进行排序.
但是当我写这样的测试时:
public class Test {
public static void main (String a[]) {
Queue<Integer> queue = new PriorityQueue<Integer>();
for (int i = 1; i <= 20; i++) {
queue.offer(i);
}
System.out.println(queue);
Queue<Integer> queue2 = new PriorityQueue<Integer>();
for (int i = 20; i >= 1; i--) {
queue2.offer(i);
}
System.out.println(queue2);
}
}
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
[1, 2, 7, …
Run Code Online (Sandbox Code Playgroud) 我有一个正常的数据库调用,从我的数据库收集信息.我使用这些信息来创建我的对象(CallQueue
)然后将这些对象添加到列表中,然后返回列表.
突然间我发现我原来的代码没有按预期工作,因为我创建了dublicates,所以现在我试图取消任何dublicates被创建!但有个问题!
我无法遍历我的列表并检查是否已创建对象!
这是我的代码:
while (query.next()) {
if (!queues.isEmpty()) {
/*This gives the Execption->*/
for (CallQueue callQueue : queues) {
if (callQueue.getType().equals(query.getString("KØ"))) {
double decimalTime = query.getDouble("TID");
int hourOfDay = (int)Math.round(24 * decimalTime);
int callAmount = query.getInteger("ANTAL_KALD");
if (hourOfDay > 19) {
hourOfDay = 19;
}
callQueue.addCallsByTime(hourOfDay, callAmount);
} else {
String queueName = query.getString("Kø");
if (!queueName.equalsIgnoreCase("PrivatOverflow")) {
CallQueue cq = new CallQueue(query.getString("KØ"));
double decimalTime = query.getDouble("TID");
int hourOfDay = (int)Math.round(24 * decimalTime);
int callAmount = query.getInteger("ANTAL_KALD");
if …
Run Code Online (Sandbox Code Playgroud)