List of usage examples for org.openqa.selenium.chrome ChromeDriver ChromeDriver
public ChromeDriver()
From source file:fr.lip6.segmentations.BrowserRep.java
License:Open Source License
public void setLocalDriver() { switch (this.desc) { case "firefox": this.driver = new FirefoxDriver(); break;/* ww w . ja va 2 s . co m*/ case "iexplorer": this.driver = new InternetExplorerDriver(); break; case "chrome": this.driver = new ChromeDriver(); break; case "opera": this.driver = new OperaDriver(); break; case "htmlunit": this.driver = new HtmlUnitDriver(); break; } setJSDriver(); this.driver.manage().timeouts().pageLoadTimeout(MAX_WAIT_S, TimeUnit.SECONDS); this.driver.manage().timeouts().implicitlyWait(MAX_WAIT_S, TimeUnit.SECONDS); this.driver.manage().window().setSize(new org.openqa.selenium.Dimension(1024, 768)); }
From source file:GlennsPack.GlennWebAPI.Bot2048.java
License:Open Source License
public Bot2048() { System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().setSize(new Dimension(2000, 800)); driver.get("http://annimon.github.io/16384/"); // try { // Thread.sleep(2000); // } catch (Exception e) { // // FIXME: handle exception // }//from w w w .j a v a2s .c om // WebElement element = driver.findElement(By.xpath("/html/body/div")); // ("/html/body/div/div[2]")); Actions actions = new Actions(driver); actions.moveToElement(element); actions.click(); CharSequence[] array = { Keys.ARROW_DOWN, Keys.ARROW_LEFT, Keys.ARROW_RIGHT }; for (int i = 0; i < 1000000; i++) { Random random = new Random(); actions.sendKeys(array[random.nextInt(3)]); ; actions.sendKeys(Keys.ARROW_DOWN); actions.build().perform(); try { // Thread.sleep(1); } catch (Exception e) { // FIXME: handle exception } } }
From source file:GlennsPack.GlennWebAPI.Example.java
License:Open Source License
public void gojbSpam() { System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().setSize(new Dimension(2000, 800)); driver.get("http://gojb.ml/chat"); try {/*from ww w. j av a 2 s . c o m*/ Thread.sleep(500); } catch (InterruptedException e1) { // FIXME Auto-generated catch block e1.printStackTrace(); } driver.findElement(By.xpath("//*[@id=\"menu\"]/div/ul/li[1]/div/p")).click(); ; driver.findElement(By.id("knapp")).click(); try { Thread.sleep(2000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } driver.switchTo().alert().sendKeys("GoJbBot"); driver.switchTo().alert().accept(); driver.findElement(By.id("knapp2")).click(); for (int i = 0; i < 1000; i++) { str = ""; for (int i1 = 0; i1 < 10; i1++) { str = str + abc.charAt(rand.nextInt(abc.length())); } driver.findElement(By.id("chat")).sendKeys(str, Keys.ENTER); } }
From source file:GlennsPack.GlennWebAPI.Example.java
License:Open Source License
public void twitterSpam() { System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().setSize(new Dimension(2000, 800)); driver.get("https://twitter.com/login"); driver.findElement(By.xpath("//*[@id=\"page-container\"]/div/div[1]/form/fieldset/div[1]/input")) .sendKeys("kakansbot"); driver.findElement(By.xpath("//*[@id=\"page-container\"]/div/div[1]/form/fieldset/div[2]/input")) .sendKeys("falcor1122"); driver.findElement(By.xpath("//*[@id=\"page-container\"]/div/div[1]/form/div[2]/button")).click(); millisAtStart = System.currentTimeMillis(); try {// w w w. j a va 2s .co m for (int i = 0; i < 100; i++) { str = ""; for (int i1 = 0; i1 < 10; i1++) { str = str + abc.charAt(rand.nextInt(abc.length())); } driver.findElement(By.xpath("//*[@id=\"global-new-tweet-button\"]")).click(); try { Thread.sleep(500); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } driver.findElement(By.id("tweet-box-global")).sendKeys(str); try { Thread.sleep(500); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } driver.findElement( By.xpath("//*[@id=\"global-tweet-dialog-dialog\"]/div[2]/div[4]/form/div[2]/div[2]/button")) .click(); x++; System.out.println("Nu har " + x + " tweets skickats, " + (int) ((System.currentTimeMillis() - millisAtStart) / 1000) + " sekunder efter start"); if (lastMillis > 0) { System.out.println("Senaste tweetet skickades fr " + (int) ((System.currentTimeMillis() - lastMillis) / 1000) + " sekunder sen"); } lastMillis = System.currentTimeMillis(); System.err.println(""); try { Thread.sleep(1000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } } } catch (Exception e) { driver.close(); twitterSpam(); } driver.close(); }
From source file:GlennsPack.GlennWebAPI.Example.java
License:Open Source License
public static void testGoogleSearch() { // Optional, if not specified, WebDriver will search your path for chromedriver. System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://whatismybrowser.com"); try {// www . ja va 2 s. c om Thread.sleep(5000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } // Let the user actually see something! WebElement searchBox = driver.findElement(By.name("q")); searchBox.sendKeys("ChromeDriver"); searchBox.submit(); try { Thread.sleep(5000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } // Let the user actually see something! driver.quit(); }
From source file:GlennsPack.GlennWebAPI.findTextInPage.java
License:Open Source License
public findTextInPage(ArrayList<String> lookFor) { System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().setSize(new Dimension(2000, 800)); driver.get("http://gojb.ml/chat"); try {/*from w w w .j a v a 2 s. c o m*/ Thread.sleep(500); } catch (InterruptedException e1) { // FIXME Auto-generated catch block e1.printStackTrace(); } driver.findElement(By.xpath("//*[@id=\"menu\"]/header/div[1]")).click(); driver.findElement(By.id("knapp")).click(); try { Thread.sleep(2000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } driver.switchTo().alert().sendKeys("GoJbBot"); driver.switchTo().alert().accept(); driver.findElement(By.id("knapp2")).click(); while (found != true) { try { for (int index = 0; index < lookFor.size(); index++) { List<WebElement> element = driver .findElements(By.xpath("//*[contains(translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ'," + "'abcdefghijklmnopqrstuvwxyz'),\"" + lookFor.get(index).toLowerCase() + "\")]")); for (int i = 0; i < element.size(); i++) { if (!mathingsFound.contains(element.get(i).getText())) { mathingsFound.add(element.get(i).getText()); System.out.println("FOUND!"); Found(lookFor.get(index).toLowerCase(), element.get(i).getText(), driver); } else { missmatch++; if ((missmatch * lookFor.size()) == element.size()) { System.out.println("OR ELSE"); throw new Exception(); } } } } } catch (Exception e2) { } try { Thread.sleep(1000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } } }
From source file:GlennsPack.GlennWebAPI.TwitchBot.java
License:Open Source License
public TwitchBot(ArrayList<String> lookFor) { System.setProperty("webdriver.chrome.driver", "C:/Users/Glenn/Downloads/chromedriver/chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().setSize(new Dimension(2000, 800)); driver.manage().deleteAllCookies();/*from w w w . j ava2 s . c o m*/ // driver.get("http://twitch.tv/login"); // // driver.findElement(By.id("username")).sendKeys("kakansbot"); // driver.findElement(By.xpath("//*[@id=\"loginForm\"]/div[2]/input")).sendKeys("falcor1122"); // driver.findElement(By.xpath("//*[@id=\"loginForm\"]/div[3]/input")).click(); // // driver.get("http://www.twitch.tv/kakan9898/chat"); driver.get("https://api.twitch.tv/kraken/oauth2/authorize" + "?response_type=token&client_id=ic1pa8ll9hazkssp35klwsmpelqejqj&redirect_uri=http://twitch.tv/kakan9898/chat&scope=chat_login"); try { driver.findElement(By.xpath("//*[@id=\"header_login\"]/span")).click(); } catch (Exception e) { // FIXME: handle exception } driver.findElement(By.xpath("//*[@id=\"login\"]")).sendKeys("kakansbot"); driver.findElement(By.xpath("//*[@id=\"password\"]")).sendKeys("--"); driver.findElement(By.xpath("//*[@id=\"oauth_submit\"]")).click(); try { driver.findElement(By.xpath("//span[contains(text(),'Authorize')]")).click(); } catch (Exception e) { // FIXME: handle exception } try { Thread.sleep(5000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); } try { driver.findElement(By.xpath("//*[@id=\"noty_796318084299728000\"]/div/div[2]/svg")).click(); } catch (Exception e) { // FIXME: handle exception } driver.findElement(By.id("ember673")).sendKeys("I am now monotoring this chat! Be aware!", Keys.ENTER); while (found != true) { try { for (int index = 0; index < lookFor.size(); index++) { List<WebElement> element = driver.findElements( By.xpath("//*[contains(translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ',\'" + abc + "\'),\"" + lookFor.get(index).toLowerCase() + "\")]")); for (int i = 0; i < element.size(); i++) { if (!(mathingsFound.contains(element.get(i)))) { mathingsFound.add(element.get(i)); if (index < amounOfHello) { sortOfText = "greet"; System.out.println(index + " <- index --- amountHello -> " + amounOfHello); } else if (index >= amounOfHello && index < (amounOfHello + amountOfBye)) { sortOfText = "bye"; } else { sortOfText = "emoji"; } System.out.println("FOUND " + lookFor.get(index) + "!"); System.err.println(element.get(i)); FoundString(lookFor.get(index).toLowerCase(), element.get(i).getText().toLowerCase(), driver, sortOfText); } else { missmatch++; if ((missmatch * lookFor.size()) == element.size()) { System.out.println("OR ELSE"); throw new Exception(); } } } } try { for (int i1 = 0; i1 < memesToLookFor.size(); i1++) { List<WebElement> element = driver .findElements(By.xpath("//img[@alt='" + memesToLookFor.get(i1) + "']")); for (int i = 0; i < element.size(); i++) { if (!(mathingsFound.contains(element.get(i)))) { mathingsFound.add(element.get(i)); sortOfText = "meme"; FoundMeme(memesToLookFor.get(i1), driver); } } } } catch (Exception e) { // FIXME: handle exception } } catch (Exception e2) { e2.printStackTrace(); System.out.println("Still running though"); } try { Thread.sleep(1000); } catch (InterruptedException e) { // FIXME Auto-generated catch block e.printStackTrace(); System.out.println("Still running though"); } } }
From source file:google.TestGoogle.java
/** * @param args the command line arguments *//*w ww .j a va2 s . c om*/ public static void main(String[] args) throws InterruptedException { System.setProperty("webdriver.chrome.driver", "D:\\GitHub\\java\\Gradle\\SeleniumTest\\exe\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.get("http://bbs.sgcn.com/member.php?mod=logging&action=login"); Thread.sleep(5000); // Let the user actually see something! //WebElement searchBox = driver.findElement(By.name("q")); //searchBox.sendKeys("ChromeDriver"); //searchBox.submit(); driver.findElement(By.id("u_u")).sendKeys("?"); driver.findElement(By.id("u_p")).sendKeys("diesel"); driver.findElement(By.className("u_s1")).submit(); Thread.sleep(5000); driver.findElement(By.className("bind_skip")).submit(); driver.get("http://bbs.sgcn.com/thread-15716879-1-1.html"); JavascriptExecutor jse = (JavascriptExecutor) driver; WebElement we = driver.findElement(By.id("fastpostsubmit")); jse.executeScript("arguments[0].scrollIntoView(true);", we); driver.findElement(By.id("fastpostsubmit")).click(); Thread.sleep(5000); // Let the user actually see something! driver.quit(); }
From source file:gov.nih.nci.firebird.commons.selenium2.test.WebDriverModule.java
License:Open Source License
@Provides @Singleton//from w w w. j av a2 s. c o m @Named("selenium.chrome.driver") public WebDriver provideChromeDriver() { final WebDriver driver = new ChromeDriver(); closeDriverOnShutdown(driver); return driver; }
From source file:GUI.AfterLogin.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: String domain = "http://google.com"; String appId = "1716266622025825"; String authUrl = "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=" + appId + "&redirect_uri=" + domain + "&scope=user_about_me," + "user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_birthday,user_education_history," + "user_events,user_photos,user_friends,user_games_activity,user_hometown,user_likes,user_location,user_photos,user_relationship_details," + "user_relationships,user_religion_politics,user_status,user_tagged_places,user_videos,user_website,user_work_history,ads_management,ads_read,email," + "manage_pages,publish_actions,read_insights,read_page_mailboxes,rsvp_event"; System.setProperty("webdirver.chrome.driver", "chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get(authUrl);//from ww w . j a v a 2s. c om String accessToken; while (true) { if (!driver.getCurrentUrl().contains("facebook.com")) { String url = driver.getCurrentUrl(); accessToken = url.replaceAll(".*#access_token=(.+)&.*", "$1"); driver.quit(); fbClient = new DefaultFacebookClient(accessToken); try { // Obtem os dados do utilizador UserData userdata = new UserData(fbClient); user = userdata.getUser("me"); Interface it = new Interface(); this.jButton2.setEnabled(true); this.jButton3.setEnabled(true); this.textField.setEnabled(true); this.jComboBox1.setEnabled(true); this.jComboBox2.setEnabled(true); this.jComboBox3.setEnabled(true); this.jLabel3.setEnabled(true); this.jLabel4.setEnabled(true); this.jLabel7.setEnabled(true); this.jLabel11.setEnabled(true); this.jButton4.setEnabled(false); this.setName(user.getName()); } catch (Exception e) { e.printStackTrace(); } } } }