Import Java.util.concurrent.timeunit;import Org.openqa.selenium.by;import Org.openqa.selenium.webdriver;import Org.openqa.selenium.firefox.firefoxdriver;import Org.openqa.selenium.firefox.firefoxprofile;import Org.openqa.selenium.firefox.internal.profilesini;import org.openqa.selenium.support.ui.ExpectedConditions; Import Org.openqa.selenium.support.ui.webdriverwait;public class Feizong {public static void main (string[] args) {// TODO auto-generated Method Stubsystem.setproperty ("Webdriver.firefox.bin", "F:\\program Files (x86) \\Mozilla firefox\ \firefox.exe "); Profilesini ini = new Profilesini (); Firefoxprofile profile = Ini.getprofile ("Default"); Webdriver Driver = new Firefoxdriver (profile);d river.get ("http://www.cnblogs.com/");d river.manage (). window (). Maximize ();d river.findelement (By.xpath ("//a[text () = ' login ']"). Click ();//Blog Park account driver.findelement (by.id ("INPUT1")) . SendKeys ("xxxxxx");//Blog Park password driver.findelement (by.id ("Input2")). SendKeys ("xxxxxx");d river.findelement (By.id (" Signin ")). Click (); Webdriverwait wait = new Webdriverwait (driver, 5);//Login account name Wait.until (expectedconditions.presenceofelementlocated ( By.xpath ("//a[text () = ' southerly _real ')")));d River.get ("Http://www.cnblogs.com/zhangfei");// The title of the article to be commented Driver.findelement (By.xpath ("//a[text () = ' Use of the ireporter interface of ' testng ')"). Click ();//Blog Park can only comment 6 times for (int i = 0; i < 6; i++) {driver.findelement ("by.id (" Tbcommentbody ")). SendKeys (" Fly the total, I'm going to brush the comments "+i);d river.findelement (by.id (" Btn_comment_ Submit "). Click ();d river.manage (). Timeouts (). implicitlywait (1, timeunit.seconds);}}
Use Webdriver Brush Fly Total blog post comments