hi i'm trying to click on a button using Xpath on chrome browser but from some reason the software does not click on it. i used the devtools inspect in order to copy the Xpath to the findElement function. that's the website: https://mynames.co.il/ i'm sorry that's in hebrew...
this photo shows the button ,i marked the button in blue
that's the steps file:
package stepDefinitions;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
import cucumber.api.PendingException;
import cucumber.api.java.After;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
public class purchaseDomainSteps {
WebDriver driver;
@Before
public void setup() throws IOException {
System.setProperty("webdriver.chrome.driver", Paths.get(System.getProperty("user.dir")).toRealPath() + "\\src\\test\\java\\drivers\\chromedriver.exe");
this.driver = new ChromeDriver();
this.driver.manage().window().maximize();
this.driver.manage().timeouts().pageLoadTimeout(120, TimeUnit.SECONDS);
}
@After()
public void tearDown() {
this.driver.manage().deleteAllCookies();
this.driver.quit();
}
@Given("^I access https://mynames\\.co\\.il$")
public void i_access_https_mynames_co_il() throws Throwable {
driver.get("https://mynames.co.il/");
throw new PendingException();
}
@When("^I click on Login button\\.$")
public void i_click_on_Login_button() throws Throwable {
String path = "/html/body/div[1]/div/div/section[2]/div/div/div[2]/div/div/section/div/div/div[2]/div/div/div/div/div/a/span/span";
//WebDriverWait wait = new WebDriverWait(driver, 5);
driver.findElement(By.xpath(path)).click();
throw new PendingException();
}
that's the runner class:
package runners;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(features = { "src/test/java/featurefiles/" }, glue = {
"stepDefinitions" }, monochrome = true, tags = {},
plugin = { "pretty", "html:target/cucumber", "json:target/cucumber.json",
"com.cucumber.listener.ExtentCucumberFormatter:output/report.html" })
public class MainRunner {
}