I'm new to test automation in Java with Selenium and the Cucumber plugin. I need to click on an object on a website without identifying xpath, but simply declaring its position on the horizontal and vertical axis of the screen. How can I do it?
How do I identify it by analyzing the page and what is the listing in Selenium with Cucumber?
I'm new to test automation in Java with Selenium and the Cucumber plugin. I need to click on an object on a website without identifying xpath, but simply declaring its position on the horizontal and vertical axis of the screen. How can I do it?
How do I identify it by analyzing the page and what is the listing in Selenium with Cucumber?
If you need to click on a specific position on a webpage without using XPath, you can do it using Selenium’s Actions class in Java. Simply move to the desired x, y coordinates and perform a click. Here's a basic example.
Actions actions = new Actions(driver);
actions.moveByOffset(500, 300).click().perform();
If you are using Cucumber framework, you can use below code,
@Then("I click on coordinates {int} and {int}")
public void iClickOnCoordinates(int x, int y) {
Actions actions = new Actions(driver);
actions.moveByOffset(x, y).click().perform();
}