Home > Programming, QA, Test and Automation Stuffs > Mark element in the page with red border (Javascript with Selenium)

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 🙂

Advertisements
  1. February 9, 2016 at 4:11 am

    Thanks for the good stuff and it working in Selenium. Have any option to mark an element in Native application (if I use the tool as Appium)?

    • February 11, 2016 at 5:30 pm

      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.

  1. July 2, 2014 at 11:11 pm

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: