Friday, 2 August 2019

ElementNotInteractableException



ElementNotInteractableException::
is caused when an element is found, but you can not interact with it. For instance, you may not be able to click or send keys.

There could be several reasons for this:

1. Wait until an element is visible / clickable
WebDriverWait wait = new WebDriverWait(driver, timeout);
wait.until(ExpectedConditions.visibilityOf(element));
wait.until(ExpectedConditions.elementToBeClickable(element));

2. Add Implicit wait

what is stale element exception - how to fix it


Stale = left over / old

if an element changes its position and then if you are trying to perform some event on top of it then we get stale element exception.

below are the fixes

wait.until(ExpectedConditions.visiblityofElementToBeClickable(By.id(“id”)))

wait.until(ExpectedConditions.presenceOfElementLocated(By.id("id")));

wait.until(ExpectedConditions.refreshed(ExpectedConditions.stalenessOf("table")));

Interview qns on final keyword | java

1) Java final variable
If you make any variable as final, you cannot change the value of final variable(It will be constant).

2) Java final method
If you make any method as final, you cannot override it.

3)Java final class
If you make any class as final, you cannot extend it.

Q)Is final method inherited?
Ans) Yes, final method is inherited but you cannot override it. For Example:

Q)Can we initialize blank final variable?
Yes, but only in constructor. For example:

Q)static blank final variable
A static final variable that is not initialized at the time of declaration is known as static blank final variable. It can be initialized only in static block.

Q) What is final parameter?
If you declare any parameter as final, you cannot change the value of it.   int cube(final int n){ n = n+2; }

Q)Can we declare a constructor final?
No, because constructor is never inherited.