2

I have an element on a website which looks like below

        <div id="wrapperCategory" class="categoryItemWrapper">
        <div class="panel panel-default panel-categoryItem text-center categoryItem disabledItem" ng-class="category.CategoryStyleClass" ng-click="setselectedProduct(productIndex,product,category); setselectedProductAmount(null);" title="Category">
            <div class="panel-heading">
                Category
            </div>
            <div class="panel-body">
                Price
            </div>
            <div class="panel-footer availability" ng-class="category.AvailabilityStyleClass">
                <span ng-bind-html="category.AvailabilityText">Avail</span>
            </div>
        </div>
    </div>

I need to click on it to get forward. If I manually click on each of these divs or on span website goes forward but SeleniumWebdriver can't click any of them. I tried click on span and on div with ng-click event buch each time i get an error:

Exception in thread "main" org.openqa.selenium.WebDriverException: Element <div class="panel panel-default panel-categoryItem text-center categoryItem" ng-class="category.CategoryStyleClass" ng-click="setselectedProduct(productIndex,product,category); setselectedProductAmount(null);" title="Category"></div> is not clickable at point (619.2666625976562, 474.23333740234375). Other element would receive the click: <div style="top: 0;left: 0;bottom: 0;right: 0;position: fixed;pointer-events: auto !important;z-index: 10000;" id="cover-1526454140024"></div>

I don't get it. Can I somehow check which element is clickable and which element overlaps this which I want to click (I dont'see any div with id="cover-1526454140024" in code of the website) ?

Updated: Unfortunately it still doesn't work after your solutions. The same exception when trying to click.

//    try {
//      Thread.sleep(1000);
//    } catch (InterruptedException e) {
//      e.printStackTrace();
//    }
    JavascriptExecutor js = (JavascriptExecutor) Mundial.driver;
    js.executeScript("arguments[0].scrollIntoView();", categoryItem);

    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(categoryItem));
    categoryItem.click();
    List<WebElement> selects = driver.findElements(By.tagName("select"));
    Select ticketsToSelect = new Select(selects.get(3));
    ticketsToSelect.selectByValue("number:2");

It only works in case when I put sleep and scroll down manually. I don't get it.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
kris82pl
  • 977
  • 3
  • 12
  • 21
  • 1
    Try to add wait before click event – Ankur Singh May 16 '18 at 07:22
  • 1
    Possible duplicate of [Element MyElement is not clickable at point (x, y)... Other element would receive the click](https://stackoverflow.com/questions/44724185/element-myelement-is-not-clickable-at-point-x-y-other-element-would-receiv) – undetected Selenium May 16 '18 at 07:25
  • 1
    when your script is running and if you are visualizing , would you able to see the element and still getting the error ? or would you have to scroll down or may be perform some action to see the element interaction. – cruisepandey May 16 '18 at 07:41
  • add your code trials , that'd be helpful – cruisepandey May 16 '18 at 07:41
  • I have much experience with this kinds of errors, but it's very difficult to solve. Please share the web page with us. – Happy Bird May 16 '18 at 09:27
  • 1
    @cruisepandey That's the solution. I don't see this element and need to scroll down and then it works. Thanks :) – kris82pl May 16 '18 at 10:18
  • Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-x-y-other-elem) – Mate Mrše Sep 25 '19 at 08:18
  • Does this answer your question? [Debugging "Element is not clickable at point" error](https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error) – Prophet Jun 04 '21 at 06:49

5 Answers5

4

As per your response :

You will have to scroll down to let the web element available to your script.For that you can use this code :

public static void scrollDown(WebDriver driver, String YoffSet){
            JavascriptExecutor jse = (JavascriptExecutor)driver;
            jse.executeScript(YoffSet);
    }

here you can call this method anywhere from your code.

Then you can use this code to interact with the web element :

WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("static ID")));  
element.click();
cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • Unfortunately it doesn't work if I don't scroll manually. I updated first post with my code. Can you take a look ? – kris82pl May 16 '18 at 18:41
  • @kris82pl : there are multiple ways to scroll down , I will post the code in comment section one by one. – cruisepandey May 17 '18 at 06:04
  • JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("window.scrollBy(0,500)", ""); – cruisepandey May 17 '18 at 06:05
  • Actions action = new Actions(driver); action.sendKeys(Keys.PAGE_DOWN).build().perform(); – cruisepandey May 17 '18 at 06:06
  • you can call sendKeys(Keys.PAGE_DOWN) multiple times as per your requirement. Like this : action.sendKeys(Keys.PAGE_DOWN).sendKeys(Keys.PAGE_DOWN).build().perform(); – cruisepandey May 17 '18 at 06:06
0

I experienced lot of such issues, as Ankur says, use wait before click

WebElement seems_unclickable = wait.until(ExpectedConditions.elementToBeClickable(By.id(...
pburgr
  • 1,722
  • 1
  • 11
  • 26
0

One of the way is ExpectedConditions commands

WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("Yourid")));

More examples can be found at http://toolsqa.com/selenium-webdriver/wait-commands/

Prany
  • 2,078
  • 2
  • 13
  • 31
0

Try "scrollIntoView".

public void ScrollElementIntoView(IWebElement element)
    {
        var js = driver as IJavaScriptExecutor;
        js.ExecuteScript("arguments[0].scrollIntoView()", element);
    }
MarkM
  • 43
  • 1
  • 7
0

I had the same issue and it was due to a having a non 100% zoom applied to the page body like:

body {
  zoom: 90%;
}

Removing the css zoom fixed the issue.

Laurent
  • 21
  • 1
  • 2