Reputation: 2292
For webdriverIo, we are taking xpath for an element as a return value for a function
get loginButton() {
return browser.element("//div[@class='login']");
}
But now we are keeping the same function name for Mobile browser, PC browser as well as mobile app. So my doubts are :
like :
get loginButton() {
android : return browser.element("//div[@class='android-login']");
ios : return browser.element("//li[@class='ios-login']");
chrome : return browser.element("//a[@class='pc-login']");
}
or can we write with Switch or any other methods. Please help
Upvotes: 0
Views: 41
Reputation: 432
The way I see it, you could probably use a Switch or Else-If statements (plain vanilla JS) in your function.
function loginButton(x){
if (x === "android "){
return browser.element("//div[@class='android-login']");
}
else if (x == "ios"){
return browser.element("//li[@class='ios-login']");
}else if (x == "chrome"{
return browser.element("//a[@class='pc-login']");
} else{
return -1;
};
};
The similar should be true with a Switch statement.
Upvotes: 1