大家好,我正在学习Selenium with Java。如何选择具有新帖子的论坛帖子(用户尚未发布的帖子)。
我的任务示例:
给出以下位置的线程列表:http://siteownersforums.com/forumdisplay.php?s=ea4353212d6e4bcb50abb3f5790fa97a&f=3
打开您尚未发布的每个新主题。提示:您需要 首先选择元素,然后使用.click()方法。
这就是我到目前为止所做的:
package main;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
public static void main(String[] args) {
//Set the Driver and the Webpage.
System.setProperty("webdriver.chrome.driver", "./chromedriver");
WebDriver chromeDriver = new ChromeDriver();
chromeDriver.get("http://siteownersforums.com/forumdisplay.php?s=ea4353212d6e4bcb50abb3f5790fa97a&f=3");
//Confirmation
System.out.println("Successfully Opened up: "+ chromeDriver.getTitle());
//Select each of the threads and click it.
for (int i =0; i< 27; i++){
WebElement tempThread = chromeDriver.findElement(By.cssSelector(""));
tempThread.click();
}
}//Closes method test
}//Closes class