I try doing a right-click on a position that is calculated based on the input. The input and the evaluation work already. But I don't know how to do the right-click at the found position. Does anyone know how this works in my use case? Here is the code:
public class MapAnalyser {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:/uti/PC/chromedriver/chromedriver.exe");
final ChromeDriver driver = new ChromeDriver();
driver.get("https://map.geo.admin.ch/");
final WebElement searchBar = driver.findElementByCssSelector("#search-container > div > form > span.ga-search-input-container > input");
searchBar.sendKeys("199340 825798");
final Actions action = new Actions(driver);
// The container match with the expected element
final List<WebElement> boxs = driver.findElementsByXPath("/html/body/div[5]/div[5]/div[2]/div");
System.out.println(boxs.size());
// How to perform the right click on the search position?
// Find the crosshairs and right click at this position. Right click does not work
// action.contextClick(driver.findElementsByXPath("don’t now how]").get(0)).build().perform();
// if the right click is performed the correct values are provided
new Actions(driver).moveToElement(new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(boxs.get(0)))).clickAndHold(boxs.get(0)).build().perform();
for (final WebElement element : boxs) {
System.out.println("Infos:" + element.getText());
}
}
}