im new to java selenuim, im trying to make an automate program that press on 'Connect' button on linkedin.
i tried to read a solution online with no succes.
i tried to use driver.findelement(by.id) and driver.findelement(by.class) and both didnt worked.
Thanks!
package org.example.linkedin;
import java.util.Scanner;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MainPageTest {
Scanner scan = new Scanner(System.in);
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\chromedriver.exe");
login();
Connect();
}
public static void login() throws InterruptedException {
WebDriver driver = new ChromeDriver();
Scanner scan = new Scanner(System.in);
System.out.println("please enter userName ");
String userName = scan.nextLine();
System.out.println("please enter password");
String password = scan.nextLine();
driver.navigate().to("https://www.linkedin.com/uas/login");
WebElement element = driver.findElement(By.id("username"));
element.sendKeys(userName);
WebElement element2 = driver.findElement(By.id("password"));
element2.sendKeys(password);
driver.findElement(By.className("mercado-button--primary")).click();
WebElement element3 = driver.findElement(By.id("ember26"));
element3.click();
Thread.sleep(3000);
}
public static void Connect() throws InterruptedException {
<button aria-label="Invite "" to connect" id="ember589" class="full-width artdeco-button artdeco-button--2 artdeco-button--full artdeco-button--secondary ember-view" type="button"><!---->
Connect
}
}