I like to have elementToBeClickable
to be passed dynamically to ExpectedConditions
. so I can call like this
dynamicExpectedConditions("elementToBeClickable")
dynamicExpectedConditions("invisibilityOfElementLocated")
...
and it executes this below code dynamically
WebDriverWait wait = new WebDriverWait(driver, waitTime);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(loc)));
I read that usingreflection
something of that sort can be done and so tried to write something as below. Of course it is not complete by any means but I still wanted to show in case it is useful.
ExpectedConditions
is then to be passed in until
method of WebDriverWait
because that is the final goal.
how can I achieve that or is it even in the right direction?
public void dynamicExpectedConditions(methodName){
Class<ExpectedConditions> expectedConditions = ExpectedConditions.class
Constructor <ExpectedConditions> constructor=expectedConditions.getConstructor(null);
ExpectedConditions econditions = constructor.newInstance(null);
Method method = ExpectedConditions.class.getMethod("methodName");
eConditions = (ExpectedConditions) method.invoke(eConditions, null);
}
Aucun commentaire:
Enregistrer un commentaire