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(By.id(“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 ๐Ÿ™‚

3 thoughts on “Mark element in the page with red border (Javascript with Selenium)

    1. Hey Sanoj, thanks you ๐Ÿ™‚ I used calabash and for now I am using Robotium, but depends what is your project, like I would have chosen Appium here at my work, but they don’t have any iPads and probably will never have, so for this reason I chose Robotium.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.