We need to follow few steps to make sure that the element is selected or not, Normally when we have this kind of scenario what we do is, we will use click() method to select the check box. After this, we might move on to the next step of the scenario.
Sometimes not selecting will help you, you got to make sure that the checkbox is selected. To verify it we need to use the isSelected() method and get check whether it is really selected.
var checked = $("//input[@type='checkbox']").isSelected()
if(!checked){
$("//input[@type='checkbox']").click()
}
All the links are formed using anchor tag a and all links will have href attribute with URL value. So by locating elements of tagName 'a' we can find all the links on a webpage.
We can use the following code to get all the links
$$("a")
Tooltips web elements have an attribute of type title. By fetching the value of the 'title' attribute we can verify the tooltip text in WebdriverIO.
var tooltip = $("some locator").getAttribute("title")
console.log(tooltip)
isSelected() verifies if an element is selected or not, isSelected() method returns boolean value, true if the element is selected and false if it is not.
browser.get("https://google.com")
var selectedFlag = $("//input[@id='selected'] [value='Bangalore']").isSelected()
console.log("Is element selected : "+selectedFlag);
We can accept the alert using acceptAlert()
browser.acceptAlert()
The sendKeys method on WebElement class will append the value to the existing value of the element. If you want to clear the old value. You can use clear() method.
let webElement = $("element-id");
webElement.setValue("new input value");
I am Pavankumar, Having 8.5 years of experience currently working in Video/Live Analytics project.