【发布时间】:2018-04-22 21:22:49
【问题描述】:
我需要使用 Selenium Webdriver 获取带有红色/绿色项目符号的网页上的超链接列表。可能吗?这些超链接是根据用户提供的 IP 动态生成的。 例如,当用户访问 http://www.dnsbl.info/ 并输入任何特定的 IP 地址时,我需要获取一个绿色超链接列表和另一个包含红色超链接的列表。这个场景可以使用 webdriver 自动化吗?
下面列出的是我现在的脚本:
public class SelectCategory extends Config {
public static WebDriver driver;
@Test(enabled = true)
public void Blacklist1() throws IOException {
Properties p = new Properties(GetDataFromFile());
System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver();
driver.get(p.getProperty("BLURL"));
WebElement D1 = driver.findElement(By.xpath(".//*[@id='quickcheck']/input[1]"));
D1.clear();
D1.sendKeys(p.getProperty("IP1"));
WebElement D2 = driver.findElement(By.xpath(".//*[@id='quickcheck']/input[2]"));
D2.click();
}
public Properties GetDataFromFile() throws IOException {
File F = new File("*Path of properties file");
FileInputStream fis = new FileInputStream(F);
Properties prop = new Properties();
prop.load(fis);
return prop;
}
}
【问题讨论】:
-
你的意思是这些超链接有不同的颜色?你能展示一下它们在网络或屏幕截图上的具体外观吗?
标签: css image selenium-webdriver hyperlink background-color