You need to sign in to do that
Don't have an account?
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:
</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
2. use action with offset
3. use javascriptexecutor with offset
4. execute java script with javascriptexecutor
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
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
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
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("https://gc.kis.v2.scr.kaspersky-labs.com/3266F6F089ED-EE59-44E9-7561-426095ED/vk/VkTooltipBanner.png") 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)
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
MyButton.click();