I have two selenium elements where i need to click. But these elements are with a different id.
findElement(By.id(ID_1)).click();
findElement(By.id(ID_2)).click();
findElement(By.id(ID_1)).click() should be clicked if the Class_1 is executed, if Class_2 is called, then findElement(By.id(ID_2)).click() should be clicked.
I am trying to avoid duplicate code because these above 2 find elements are inside one method which is called Class_1 and Class_2.
I tried something like this but it didn't solve my issue
if (Class_1.class)
{
findElement(By.id(ID_1)).click();
}
else if (Class_2.class)
{
findElement(By.id(ID_2)).click();
}
I am getting "Type mismatch: cannot convert from Class<Class_1> to boolean". I mean I am trying to do like this. If this is class_1, then run this, else run else if part.
Thanks for any guidance in advance.