Mark element in the page with red border (Javascript with Selenium)

Hello again, now I will give a tip of Selenium, for mark the element that you want and before this, you can take a screenshot for evidence.

First you have to import this libraries:

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;


After this, you have to call the javascript executor and give the id or other thing for find the element:

JavascriptExecutor js = (JavascriptExecutor) driver; // change the name of your WebDriver
WebElement element = driver.findElement(“element“)); // change the localizator 

js.executeScript(“arguments[0].style.border=’3px solid red'”, element); // change the name of your variable


This is very usefull for mark the element in the page.

So, just this ! Bye bye 🙂

How can I call the drivers(browsers) in Selenium with java ?

It’s simple !

you have to call the import > import org.openqa.selenium.WebDriver; and others about the browsers, like: import org.openqa.selenium.firefox.FirefoxDriver; (calls Firefox)

After this, in the class Main, declare driver:

WebDriver driver;

and Quit:

Quit quit = new Quit();

So… you have now choose what is the browser and calls the profile and set the configs, like proxy (for this reason you have to create a profile)

public class Main {

public static void main(String[] args) throws Exception {

FirefoxProfile profile = new FirefoxProfile();   // create a profile of Firefox
profile.setPreference(“network.proxy.type”, 0);   // Don’t use proxy
driver = new FirefoxDriver(profile);       // calls the browser with the configs of the profile
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);     // config the timeouts for load a page
driver.get(site);     // change site for the url that your driver will open.

quit.tearDown(driver);     // quit the driver.



You have to create the class that close the driver in class Main.

public class Main {

public static class Quit {

public void tearDown(WebDriver driver) {


and finish !

This is the first step for create a automation with selenium. Create a driver and open the browser !

Good studies for all, bye !

How we can find a line in some table with Webdriver (Selenium) ?

Hi guys, I’m very occupied in the last months, but I will post a text about catch the lines and values in some table with Webdriver (selenium) in language java. Yes, I am changing a little the subjects, this time I will help the testers, who do automation of sites.

It’s easy if you use XPath.

This table:

Apples 44%
Bananas 23%
Oranges 13%
Other 10%


You catched the first line.

If you want catch the second line, just change the number:


It’s more easy than you expected, not ?

if you want catch all the text of all lines, just write the code:

WebElement listatable = driver.findElement(By.className(“reference”));

for (int i = 0; i < listatable.getLength(); i++) {

WebElement line = driver.findElement(By.xpath(“/html/body/div[1]/div/div[4]/div[2]/div[2]/table/tbody/tr[” + i + “]”));



Fine, now you can catch the text of each line in this table !

I hope has helped the initial testers in something.

Bye bye !