Search code examples
javaseleniumbrowserstack

Unable to click on an element in Browser stack


Unable to click on an element in Browser stack Automate. The same code is running successfully in chrome/firefox.

I am using movetoelement of Actions class to click on a particular element..

Actions action = new Actions(Browser.getCurrentDriver());
action.moveToElement(dividerPageView.clickDividerDropped).click().perform();

Also used Javascript executor but no use.

{
    WebElement element = driver.findElement(By.xpath("//span[contains(@title,'Layout Container')]/following-sibling::div[1]"));
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click();", element);
}

Please suggest another way we can click on a element which is running headless.


Solution

  • You can try:

    int items = driver.findelements(by.xpath("YOUR VALUE")).count
    if(items == 1) driver.findelement(by.xpath("YOUR VALUE")).click()