Created
December 20, 2022 12:28
-
-
Save oxcar103/2b86339c28fc23fd8d200edcd689ae6a to your computer and use it in GitHub Desktop.
Lazy LinkedIn certificate publisher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void lazyLinkedIn(WebDriver driver) throws InterruptedException { | |
// Personal credentials | |
String username = <username> | |
String password = <password> | |
// List of certificates | |
List<String> certificates = new ArrayList<String>(); | |
certificates.add( <certificate ID> | |
certificates.add( <certificate ID> | |
certificates.add( <certificate ID> | |
certificates.add( <certificate ID> | |
certificates.add( <certificate ID> | |
// Login | |
driver.get("https://www.linkedin.com/login"); | |
WebElement usernameInput = driver.findElement(By.id("username")); | |
WebElement passwordInput = driver.findElement(By.id("password")); | |
WebElement loginBtn = driver.findElement(By.xpath("//*[contains(@type, \"submit\")]")); | |
usernameInput.sendKeys(username); | |
passwordInput.sendKeys(password); | |
loginBtn.click(); | |
// Loading... | |
wait(driver,5); | |
// Repeating for each certificate | |
for(String index: certificates) { | |
driver.get("https://www.linkedin.com/sharing/share-offsite/?url=http%3A%2F%2Fude.my%2F" + index); | |
// Search and click button | |
WebElement shareButton = driver | |
.findElement(By.xpath("//*[contains(@id, \"ember\") and contains(@class, \"button\")]")); | |
shareButton.click(); | |
// Loading... | |
wait(driver, 5); | |
// Search and click another button | |
shareButton = driver | |
.findElement(By.xpath("//*[contains(@id, \"ember\") and contains(@class, \"primary\")]")); | |
// This button needs a wait to work | |
Thread.sleep(500); | |
shareButton.click(); | |
// Loading... | |
wait(driver, 5); | |
} | |
} | |
public static void main(String[] args) throws InterruptedException { | |
System.setProperty("webdriver.chrome.driver", <chromedriver.exe location>); | |
WebDriver driver = new ChromeDriver(); | |
driver.manage().window().maximize(); | |
lazyLinkedIn(driver); | |
driver.quit() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment