Skip to content

Instantly share code, notes, and snippets.

@Terkea
Created May 25, 2019 18:58
Show Gist options
  • Save Terkea/73cf658c16ee03d90c62553ac67ed84f to your computer and use it in GitHub Desktop.
Save Terkea/73cf658c16ee03d90c62553ac67ed84f to your computer and use it in GitHub Desktop.
facebook login and scroll till the bottom of the profile
package application;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static String DRIVERLOCATION = "H:\\java\\browser_drivers\\chrome\\chromedriver.exe";
public static String USERNAME = "";
public static String PASSWORD = "";
public static String PROFILE = "";
public static void main(String[] args) throws NoSuchElementException, InterruptedException {
System.setProperty("webdriver.chrome.driver", DRIVERLOCATION);
//GET RID OF NOTIFICATIONS
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.notifications", 2);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.facebook.com");
driver.findElement(By.id("email")).sendKeys(USERNAME);
driver.findElement(By.id("pass")).sendKeys(PASSWORD);
driver.findElement(By.xpath("//input[starts-with(@id, 'u_0_')][@value='Log In']")).click();
driver.get("https://www.facebook.com/" + PROFILE);
while(true){
((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment