小编Ami*_*dha的帖子

如何使用Java在Selenium WebDriver中选择下拉列表值

我是selenium的新手,目前正在研究selenium webdriver我想从下拉列表中选择一个值.id = periodId和选项很多,我试图选择过去52周.

这是Html标签:

<select id="periodId" name="period" style="display: none;">
    <option value="l4w">Last 4 Weeks</option>
    <option value="l52w">Last 52 Weeks</option>
    <option value="daterange">Date Range</option>
    <option value="weekrange">Week Range</option>
    <option selected="" value="monthrange">Month Range</option>
    <option value="yeartodate">Year To Date</option>
</select>
Run Code Online (Sandbox Code Playgroud)

请建议我点击下拉列表的一些方法.

我尝试使用上面的示例行但是得到错误,例如Element当前不可见,因此可能无法与命令持续时间或超时交互:32毫秒下拉值是jquery multiselect小部件格式

java selenium-webdriver

45
推荐指数
3
解决办法
35万
查看次数

如何在Selenium WebDriver中选择日期选择器

目前正在使用Selenium WebDriver并使用Java.我想date range从下拉列表中选择值.我想知道如何选择Date, Month and year日期选择器下拉列表中的值.

这是HTML标记:

<dd id="date-element">
<input id="fromDate" class="hasDatepicker" type="text" style="width:57px; padding:3px 1px; font-size:11px;" readonly="readonly" name="fromDate" value="01 Jan 2013">

<input id="toDate" class="hasDatepicker" type="text" style="width:57px; padding:3px 1px; font-size:11px;" readonly="readonly" name="toDate" value="31 Dec 2013">  
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我试过以下示例代码:

Log.info("Clicking on From daterange dropdown");
JavascriptExecutor executor8 = (JavascriptExecutor)driver;
executor8.executeScript("document.getElementById('fromDate').style.display='block';");
Select select8 = new Select(driver.findElement(By.id("fromDate")));
select8.selectByVisibleText("10 Jan 2013");
Thread.sleep(3000);

Log.info("Clicking on To daterange dropdown");
JavascriptExecutor executor10 = (JavascriptExecutor)driver;
executor10.executeScript("document.getElementById('toDate').style.display='block';");
Select select10 = new Select(driver.findElement(By.id("toDate")));
select10.selectByVisibleText("31 Dec …
Run Code Online (Sandbox Code Playgroud)

java jquery selenium selenium-webdriver

12
推荐指数
3
解决办法
9万
查看次数

为什么实体名称必须紧跟在为XML出现的实体引用中的"&"后面?

我在D:目录中有一个名为/NewFile.xml的XML文件.XML文件包含以下详细信息:

<?xml version="1.0"?>
<project>

<logindetails id="1001">
		<url>https:xxx</url>
        <username>xxx</username>
        <password>xxx</password>
</logindetails >

<kpi id="1001">
		<id_r>reports</id_r>
		<id_e>extranet</id_e>
		<id_pr>ext-pr</id_pr>
</kpi>	

<prkpi id="1001">
        <id_1>ext-pr-backlog-age</id_1>
		<id_2>ext-timetoassign-prs</id_2>
		<id_3>ext-timetodeliver-prs</id_3>
		<id_4>ext-timetoresolve-prs</id_4>
		<id_5>ext-new-prs</id_5>

</prkpi>

<filtersection id="1001">
		<visualizationId>Day,Week,Month,Quarter,Semester,Year,RD Tech Group,ICC,Center,Software Pack,Product,Project,Customer PRs,Severity,Priority</visualizationId>
		<projectId>dev/v4.3/r4/e12sqq,BATS,1523 Business IAD & Business CPE,[CoCo2M],VQM</projectId>
</filtersection>

</project>
Run Code Online (Sandbox Code Playgroud)

我在eclipse中运行的代码如下:

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;


import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.Select;
import org.w3c.dom.Document;
import …
Run Code Online (Sandbox Code Playgroud)

java xml

9
推荐指数
2
解决办法
3万
查看次数

Webdriver单击列表中的第二个元素

我正在测试的页面有2个具有相同名称的元素,我需要单击第二个元素.我可以使用以下方法获取元素:

driver.findElements(By.linkText("Services"));
Run Code Online (Sandbox Code Playgroud)

但我不知道如何click处理第二个元素.

selenium

7
推荐指数
1
解决办法
4万
查看次数

如何创建调度程序以每晚 12 点运行我的脚本 - Selenium WebDriver

  • 目前正在研究Selenium WebDriver并使用Java。我有一个名为*测试*的项目。
  • 在该项目中,我有许多Java程序,例如Login.javaTesting1.java等。
  • 场景是我想每天早上 12 点运行我的所有脚本是否有可能创建一个调度程序来自动运行我的脚本。

java testng

7
推荐指数
1
解决办法
4万
查看次数

如何在 selenium webdriver 中使用 if/else 条件?

在 selenium webdriver 中,我想在 java 中使用 if/else 条件。每一步都需要检查,需要一一执行。例如

Log.info("Clicking on Reports link");
WebElement menuHoverLink = driver.findElement(By.id("reports"));
actions.moveToElement(menuHoverLink).perform();
Thread.sleep(6000);
Run Code Online (Sandbox Code Playgroud)

在这段代码中,我需要检查 id 一旦它出现就需要执行操作,否则它需要跳过测试用例才不会失败。

java selenium-webdriver

4
推荐指数
1
解决办法
9万
查看次数

标签 统计

java ×5

selenium-webdriver ×3

selenium ×2

jquery ×1

testng ×1

xml ×1