function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Soheil A.Soheil A. 

Button not accessible via Silenium

Hi all, 

i have tried again several hours to find a solution for the following problem. I have a button in the frontend that does not have a unique name nor ID with which i can access it through silenium to click it. Only solution i have is xpath. 

This is the story: 

I try to click the button through this way: 
WebElement myButton = webDriver.findElement(By.xpath("//*[@class='here is the xpath to my button']"));
myButton.click();
it throws an exception saying this: 
</button> is not clickable at point (1851, 325). Other element would receive the click:

i have googled and found 3 possible solutions: 

1. add implicit wait
WebDriverWait wait = new WebDriverWait(webDriver, timeout);
webDriver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
element = wait.until(ExpectedConditions.elementToBeClickable(MYBUTTON));
wait.until(ExpectedConditions.elementToBeClickable(MYBUTTON)); 
MYBUTTON.click();
still the same error from above: </button> is not clickable at point (1851, 325). Other element would receive the click:

2. use action with offset
Actions action = new Actions(webDriver);
action.moveToElement(myButton, 0, -20).contextClick().perform();
action.moveToElement(myButton, 0, -20).click().perform();
action.moveToElement(myButtons, 0, -20).doubleClick().perform();
result: nothing happens. it does not click the element. but context click is shown on the button itself. strange that click does not work. 

3. use javascriptexecutor with offset
((JavascriptExecutor)webDriver).executeScript("window.scrollTo(0,"+clickableAddProduct.getLocation().x+")");
clickableAddProduct.click();
result: still the same error from above: </button> is not clickable at point (1851, 325). Other element would receive the click:

4. execute java script with javascriptexecutor
js.executeScript(	"window.document.getElementByxpath('XPATH TO MYBUTTON').click()");
Result: no such method getElementByxpath exists 

only possible solution i have test is:
- give the button an ID (for example ID="unique ID of MYBUTTON"). during runtime in the inspector of chrome (F12)
- try this below
try {
			// Find the element...
			WebElement element = MYBUTTON;

			// Step 1
			new Actions(webDriver).moveToElement(element).perform();

			// Step 2
			element.click();
		} catch (Exception e) {

			((JavascriptExecutor) webDriver).executeScript("document.getElementById('unique ID of MYBUTTON').click();");

		}

code then it works withe the java script executor line (the one in the exception). i debugged it. worked. 

please can someone help. tried so many ways. frustrating. :(

Thanks
Soheil



 
Kristen Murray 16Kristen Murray 16
Does the error message tell you what other element would receive the click?  When I have seen this kind of error, it has included information about the element that is in the way, and that has been helpful.  For example, if there is a confirmation message that appears on the page and blocks the button for a few seconds, and then fades away, I have used method like this to wait for the confirmation message to get out of the way:
public void waitForConfirmationMessageToFade(int seconds) {
		(new WebDriverWait(driver,seconds)).until(
				new ExpectedCondition<Boolean>() {
					
					@Override
					public Boolean apply(WebDriver dr) {
						List<WebElement> successMessages=
								dr.findElements(By.className("slds-theme--success"));
						if (successMessages.size()>0) {
							return false;
						}
						return true;
			
					}


					
				});
		
	}

 
Robin BarnwellRobin Barnwell
I've got exaclty this issue:

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://login.salesforce.com/");
        driver.findElement(By.name("username")).sendKeys("a@b.com");
        driver.findElement(By.name("pw")).sendKeys("password");    
        driver.findElement(By.name("Login")).click();
    }

The problem line is the click on the Login button.  I've tried XPath and other methods and the element is found fine.  It just doesn't seem to accept the click:

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <input class="button r4 wide primary" type="submit" id="Login" name="Login" value="Log In"> is not clickable at point (254, 383). Other element would receive the click: <div style="position: relative; display: block; height: auto; width: auto; padding: 35px 10px 11px; margin: 0px; text-align: left; border: 1px solid rgb(178, 178, 178); border-radius: 5px; background: url(&quot;https://gc.kis.v2.scr.kaspersky-labs.com/3266F6F089ED-EE59-44E9-7561-426095ED/vk/VkTooltipBanner.png&quot;) 10px 9px no-repeat rgb(255, 255, 255); z-index: 2147483646;">...</div>
  (Session info: chrome=61.0.3163.100)
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
 
Robin BarnwellRobin Barnwell
Try this instead:  myButton.submit();
chinal patelchinal patel

Frustrating with same issues.. Nothing works other that when I use 

Driver.navigate.refresh();
MyButton.click();

But then I am lossing all cookies coming from previous page

chinal patelchinal patel
**Driver.navigate().refresh();
MyButton.click();
Greg Palios 5Greg Palios 5
I had a similar problem. I tried implimenting waits, but would still get the same error you were. It may be that the element on your page is persisting, but not clickable when Selenium is making the attempt. In the end, I just did used a Thread.sleep(5000); to make it just wait 5 seconds until the element was clickable. You could make it longer if needed, but I found 5 seconds worked for me.