Web element! Where are you?

We have so many tasks to be done on a webpage. For instance, we might search, click a link, download a file, upload a file and so on. For all these operations, we have to find the respective element and click that. In our code also, we are going to do the same. Let’s find out how to find the elements.

It’s time to know what’s behind your browser

In order to find the web elements for scripting our automation program, we need to have a browser. I will be explaining this tutorial with Chrome.

I hope you remember in the previous example, we have seen a line of code,driver.findElement(By.name("q")).sendKeys("Smile Please");. Now lets know deeper about this.

So far in our example, we have opened a web page (google.com), but what do we do with google? We will search isn’t it? Let’s say I want to search the term “say cheese”. Let’s find how to do that in code.

First we have to find the web element (the search box). Right click on your browser, you can see an option called _Inspect element _click on that.

As you can see from the highlighted attributes,we can select the web element by name,id,class,xpath and several other attributes.

For this example, I have selected the search box by name and sent the input via sendKeys() method to enter the search term.

results matching ""

    No results matching ""