WebdriverIO interview Questions

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 checkbox. 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 'title' attribute we can verify the tooltip text in WebdriverIO.

var tooltip = $("some locator").getAttribute("title")
console.log(tooltip)

For testing angular applications, we would be using the protractor browser automation tool.

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 the clear() method.

let webElement = $("element-id");
webElement.setValue("new input value");
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • Amol
    I have que for u,
    Can we use both,  if I want to work on Selenium With Java or I want to work on Selenium With Python, On the same Eclipse?
    I am using Eclipse Mars 2...
    
    So plz mail me your suggestion.
    
    
    Reply
    • karthiQ [ admin]
      Hi Amol,
      
      You can use Java and Python in same eclipse but not for same project.
      
      This page shows how to install pydev : http://chercher.tech/python/install-selenium-python
      
      After installtion you just need to change the perspective to PyDev
      
      I also mailed you the screenshot my eclipse which works in python and Java
      Reply