I'm able to automate the login process. I would like to automatically click on features within the page AFTER i log in but it looks like the issue is with the login credentials. So it won't automatically click on any fields. The code below is up to that point of automated login. Any suggestions?
I was expecting to be able to automate the clicking of links. At the bottom, I successfully open a new random browser and the close the page and quit the browser**
package stepDefinitions;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.time.Duration;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import io.cucumber.java.en.And;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
public class GreenKartStepDefinition {
public static WebDriver driver;
@Given("User is on ***** login page")
public static void User_is_on_****_login_page() {
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\********\\Downloads\\chromedriver\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--remote-allow-origins=*");
DesiredCapabilities cp = new DesiredCapabilities();
cp.setCapability(ChromeOptions.CAPABILITY, options);
options.merge(cp);
driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("https://*******");
}
@When("user log in with Shortname {string}")
public void user_log_in_with(String shortName) throws InterruptedException
{
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"login_user_name\"]")).sendKeys("*******");
driver.findElement(By.xpath("//*[@id=\"login_password\"]")).sendKeys("*********");
driver.findElement(By.xpath("//*[@id=\"login_contents\"]/fieldset/button")).click();
}
@Then("user is on research cloud home page")
public void user_is_on_research_cloud_home_page()
{
Properties prop = new Properties();
try {
InputStream input = new FileInputStream("C:\\Users\\*******\eclipse-workspace\\***********\\src\\test\\java\\Config\\config.properties");
prop.load(input);
System.out.println(prop.getProperty("username"));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.get("https://*****.com");
driver.close();
driver.quit();
}
}