I know i have seen this Question on StackOverFlow but not i am not able to solve my problem:
Error :
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <input type="password" id="Password" name="Password" value="" maxlength="25" placeholder=" " > is not clickable at point (446, 716). Other element would receive the click: <label for="Password">...</label>
(Session info: chrome=99.0.4844.83)
HTML:
<input type="password" id="Password" name="Password" value="" maxlength="25" placeholder=" " >
XPATH AND CSS
@FindBy(css = "#Password")
public WebElement password;
@FindBy(xpath = "//input[@id='Password']")
public WebElement password;
My code:
wait.until(ExpectedConditions.elementToBeClickable(password)).click();
wait.until(ExpectedConditions.elementToBeClickable(password)).sendKeys(PASSWORD);
Even JAVASCRIPT Click is not working
executor.executeScript("arguments[0].click();", element);
This is happening for all Checkboxes / input fields on this page. Any solution would be helpful.
CodePudding user response:
This error message...
org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <input type="password" id="Password" name="Password" value="" maxlength="25" placeholder=" " > is not clickable at point (446, 716). Other element would receive the click: <label for="Password">...</label>
(Session info: chrome=99.0.4844.83)
...implies that the <input>
element is not clickable as the <label>
element intercepts the click.
Deep Dive
Presumably the <input>
element is preceeded by <label>
element as follows:
<label for="Password" ...>
<input type="password" id="Password" name="Password" value="" maxlength="25" placeholder=" " >
Solution
In such cases, instead of the <input>
element, you need to target the <label>
element as follows:
Using css:
@FindBy(css = "label[for='Password']") public WebElement password;
Using xpath:
@FindBy(xpath = "//label[@for='Password']") public WebElement password;
and finally:
wait.until(ExpectedConditions.elementToBeClickable(password)).sendKeys(PASSWORD);
References
You can find a couple of relevant detailed discussions in:
CodePudding user response:
Can you try using JavascriptExecutor instead of sendKeys method to send password info
JavascriptExecutor jse = ((JavascriptExecutor)driver);
WebElement email = driver.findElement(By.id("useremail"));
jse.executeScript("arguments[0].value='---your email id---';", email);