Created
August 27, 2020 18:12
-
-
Save seleniumgists/c6cd8cf77e6e111dec115edd3002b091 to your computer and use it in GitHub Desktop.
generated automatically from #selenium on seleniumhq slack
This file contains hidden or 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 final String URL = "https://www.linkedin.com/home"; | |
private static final String EMAIL = "[email protected]"; | |
private static final String TEXT = "Hola Selenium 4 (alpha 6) - automated, hola LINKEDin"; | |
private static final String PWD = "blah blah"; // pasword changed for obvious reasons | |
public static void main(String[] args) throws InterruptedException { | |
System.setProperty("webdriver.chrome.driver", "/Users/test/personal/selenium/chromedriver"); | |
// Initialize browser | |
WebDriver driver = new ChromeDriver(); | |
// Open facebook | |
driver.get(URL); | |
// Maximize browser | |
driver.manage().window().maximize(); | |
//To wait for element visible | |
//To wait for element visible | |
final WebDriverWait wait; | |
wait = new WebDriverWait(driver, Duration.ofSeconds(15), Duration.ofMillis(100)); | |
final WebElement li; | |
li = wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Sign in"))); | |
li.click(); | |
final WebElement un; | |
un = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("username"))); | |
un.click(); | |
un.sendKeys(EMAIL); | |
final WebElement pwd; | |
pwd = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("password"))); | |
pwd.click(); | |
pwd.sendKeys(PWD); | |
final WebElement si; | |
si = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[type='submit']"))); | |
si.click(); | |
final WebElement pst; | |
pst = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[data-control-name='share.sharebox_focus']"))); | |
pst.click(); | |
final WebElement pstText; | |
pstText = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("div[data-test-ql-editor-contenteditable='true']"))); | |
pstText.click(); | |
pstText.sendKeys(TEXT); | |
Thread.sleep(1000); | |
final WebElement pstB; | |
pstB = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//[@id='ember543']"))); | |
pstB.click(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment