mercredi 8 août 2018

How to use By.parameter in Selenium Java code?

I am new to selenium, I am stuck in a specific situation code wise. I am trying to write a generic code for checkboxes, like below.

public void CheckBox(By by, String element)
    {
        driver.findElement(by.by(""));
    }

The above generic code, which later can be used in Tests. Where user will use this function will pass the element and by what he needs to search. (by Xpath, id or name etc.)

I can write if_else or Switch but, that will too much of a code, is there any way where can use a direct parameter with By object or is there any other way to do this. Help is appreciated.




Aucun commentaire:

Enregistrer un commentaire