Highlight elements using JavaScriptExecutor - Selenium WebDriver Session 11

preview_player
Показать описание
Highlight element in Selenium using JavaScriptExecutor:

+Must have feature Highlight element Selenium for better execution.
In Automation, testing sometimes element highlighter plays very important role.

It helps us to track our execution flow which step is being processed. Some tools like QTP, Sahi etc. you will get this inbuilt feature.

For Selenium, we have to write small code, which simply highlights element based on our parameter values. let’s get started and see Highlight element Selenium using CSS values.

In Selenium, we can use JavascriptExecutor (interface) to execute Javascript code into webdriver.

======================================================

***Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

-~-~~-~~~-~~-~-
========================================================
Please watch: "Selenium & Automation Interview Preparation - By Naveen AutomationLabs"
-~-~~-~~~-~~-~- Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Paid courses (Recorded) videos:
📗 Get My Paid Courses at
Paid courses (Recorded) videos:
-------------------------------

✔️SOCIAL NETWORKS
--------------------------------

Support My Channel✔️Or Buy Me A Coffee
--------------------------------
✔️Thanks for watching!
देखने के लिए धन्यवाद
Благодаря за гледането
感谢您观看
Merci d'avoir regardé
Grazie per la visione
Gracias por ver
شكرا للمشاهدة
Рекомендации по теме
Комментарии
Автор

Hi Naveen, Thank you! Pasting code below for future viewers.


public static void flash(WebElement element, WebDriver driver)
{
JavascriptExecutor
String bgcolor =
for(int i=0; i<10; i++) {
changeColor("rgb(300, 0, 0)", element, driver);
changeColor(bgcolor, element, driver);
}
}
public static void changeColor(String color, WebElement element, WebDriver driver ) {
JavascriptExecutor
= '"+color+"'", element);

try {
Thread.sleep(300);
}
catch (InterruptedException e) {
}
}

gangadharasastryg
Автор

Hey Naveen, your teaching is excellent you make it so easy to understand. Really appreciate it.

viveksalgaonkar
Автор

Good job Naveen, this session really help me to understand the concept of JavaScriptExecutor. Thank you so very much.

omkarpotdar
Автор

nice video to understand this concept. Thank yu

karthikkumaresan
Автор

Hi Naveen, Please explain why driver is passed in parameter for JavascriptExecutor

humasheikh
Автор

How do we implement this in framework? for each and every element i have to add this or is there any better option?

kalyanijoshi
Автор

Hi Naveen,
How to capture the screenshot with the element highlighted state?
I want to add it my extent report, I've implemented this in my code, my code is highlighting the WebElement but in the screenshot I don't see the WebElement with highlighted state. How to achieve this with the code ? Please suggest me.
Thanks.

purushothammb
Автор

Hi Naveen, are these 65 tutorials in this playlist are sufficient to crack any selenium interview ?

swatidubey
Автор

Hello, I have highlight elements method but I need to use this method using listeners in selenium 4. I tried use driver.register(highlight) method but this is not working in selenium 4

LittleTanish
Автор

Hi Naveen, I am using eclipse and I am not being able to perform executeScript(). I am getting the error below.
The method executeScript(String, WebElement) is undefined for the type JavaScriptExecutor.
Can you please help me out with it?

kanikagupta
Автор

Hi Naveen,
A quik quation i have. I am unable to find the executescrip() method in my eclipse may there is no jar file available for this class or something else I unable to understand could you please assist.?

thank you

testautomation
Автор

Hi Naveen, At 8.08min You mention Javascriptexecutor as Class but its Interface

mayursapre
Автор

if someone is not able to see Highlight elements or flashing element .you can give some wait time between changing color like this


public static void flash(WebElement element, WebDriver driver) throws InterruptedException {

String bgcolor =

for (int i = 0; i<10; i++) {
changeColor("rgb(0, 200, 0)", element, driver);//1
Thread.sleep(500); // it will wait 0.5 second
changeColor(bgcolor, element, driver);//2
Thread.sleep(500); // it will wait 0.5 second
}
}
public static void changeColor(String color, WebElement element, WebDriver driver) {

JavascriptExecutor js = ((JavascriptExecutor) driver);
= '"+color+"'", element);

try {
Thread.sleep(20);
} catch (InterruptedException e) {
}
}

sagarpateldon
Автор

Can we achieve this by using specific XPath for multiple fields at a time and the qmetry report also shows the highlighting those fields

Bhavi
Автор

Hi Naveen, Your videos are so amazing. Its easy to understand..Excellent work.

PreetiGupta-qznw
Автор

Naveen can you please start online classes.. want to join some regular online class

ruchi
Автор

Can you please make a video of scrolling and performing some action like checking the check boxes randomly
Thank you

skjahangir
Автор

Hi Naveen, In my eclipse I am not able to use executescript(). What could be an issue ? should I need to download any jar file ?

AnuragVerma
Автор

Hi Naveen, I am getting the error Exception in thread "main" java.lang.ClassCastException: cannot be cast to
at
at
executeScript it is giving an error.how do i proceeed further to see highlight

aspp
Автор

How to capture the color while move over an element...i tried with action class .. but it comes out ..let me know if anyone know and done successfully...

fathimasyed