Highlight elements using JavaScriptExecutor - Selenium WebDriver Session 11

Поділитися
Вставка
  • Опубліковано 3 гру 2024

КОМЕНТАРІ • 75

  • @gangadharasastryg2851
    @gangadharasastryg2851 2 роки тому +4

    Hi Naveen, Thank you! Pasting code below for future viewers.
    public static void flash(WebElement element,WebDriver driver)
    {
    JavascriptExecutor js=(JavascriptExecutor)driver;
    String bgcolor = element.getCssValue("backgroundcolor");
    for(int i=0; i

  • @viveksalgaonkar1005
    @viveksalgaonkar1005 3 роки тому +2

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

  • @swatidubey4669
    @swatidubey4669 6 років тому +8

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

  • @omkarpotdar2763
    @omkarpotdar2763 2 роки тому

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

  • @kalyanijoshi6884
    @kalyanijoshi6884 5 років тому +2

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

  • @purushothammb9096
    @purushothammb9096 6 років тому +1

    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.

  • @sakshiaggarwal6199
    @sakshiaggarwal6199 6 місяців тому

    Thank you so much Naveen!!🙏🙏

  • @karthikkumaresan1091
    @karthikkumaresan1091 2 роки тому

    nice video to understand this concept. Thank yu

  • @humasheikh8911
    @humasheikh8911 7 місяців тому

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

  • @testautomation6100
    @testautomation6100 3 роки тому

    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

  • @mayursapre698
    @mayursapre698 6 років тому +5

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

  • @Bhavi585
    @Bhavi585 2 роки тому

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

  • @kanikagupta8534
    @kanikagupta8534 2 роки тому

    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?

  • @AnuragVerma29
    @AnuragVerma29 6 років тому +2

    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 ?

    • @reddy4143
      @reddy4143 3 роки тому +1

      No It will be word and please share the code to. My what's number 6303698052

    • @AnuragVerma29
      @AnuragVerma29 3 роки тому

      @@reddy4143 Thanks brother, but that problem I faced 2 years ago, but again thanks for your concern.

  • @LittleTanish
    @LittleTanish 2 роки тому

    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

  • @Ashishbains25
    @Ashishbains25 6 років тому +1

    Worked fine for me. Thanks :)

  • @bashaneerati
    @bashaneerati 4 роки тому

    Hi Naveen! .. is the any another Syntax for Jsexecutor... In your point of view it is very complex....
    Can u provide less syntax code for jsExecutor

  • @skjahangir3800
    @skjahangir3800 3 роки тому

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

  • @rajendrakumarnayak5103
    @rajendrakumarnayak5103 3 роки тому

    Hi Naveen Sir,
    I've following your videos and have understood the code well, I tried the above code on a sample website and it shows an exception error:
    Exception in thread "main" org.openqa.selenium.JavascriptException: javascript error: argument is not defined
    for the method - flash(loginBtn, driver);
    Kindly please help me understand where does it actually gets stuck.
    Regards,
    Rajendra.

    • @anumarwaha2010
      @anumarwaha2010 Рік тому

      I am also stuck at same the point . Kindly provide solution

  • @ruchi210
    @ruchi210 5 років тому +1

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

  • @aspp8137
    @aspp8137 4 роки тому

    Hi Naveen,I am getting the error Exception in thread "main" java.lang.ClassCastException: org.openqa.selenium.chrome.ChromeDriver cannot be cast to seleniumSessions.javascriptExecutor
    at seleniumSessions.javascriptExecutor.flash(javascriptExecutor.java:37)
    at seleniumSessions.javascriptExecutor.main(javascriptExecutor.java:27)
    executeScript it is giving an error.how do i proceeed further to see highlight

    • @venmathir8751
      @venmathir8751 2 роки тому

      Same for me. Did U find any solution

  • @fathimasyed4232
    @fathimasyed4232 4 роки тому

    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...

  • @SherineVishal
    @SherineVishal 4 роки тому

    Like all your videos. Thanks for sharing. One thing, do we need JavascriptExecutor object in flash class

    • @ManjunathPrabhakar
      @ManjunathPrabhakar 4 роки тому

      In this video flash is a method.
      And as per usage here JS exec is unused in flash method, hence not needed within flash. But in other method JS exec is needed since we are using css styling to applying bg color.

  • @rushikeshkhandave2011
    @rushikeshkhandave2011 5 років тому

    Hi how can we highlight list of web element using this

  • @ParasJoshiPj
    @ParasJoshiPj 5 років тому

    Hi naveen please one make video on CI CD with live example...how we can do ci cd if developer will give the new cr build for this free crm website then how i will run these script automatically.

  • @madhusmitasahoo1061
    @madhusmitasahoo1061 5 років тому

    Hi Naveen, thanks for the video. I am getting error as rgb(int, int, int) is not defined. Can you help?
    Thanks

  • @ankitsrivastava1126
    @ankitsrivastava1126 6 років тому +1

    Hi Naveen my question is if our Application does not designed form Java Script then will JS Executor work, i think not. please answer ....

  • @ravinderjill9961
    @ravinderjill9961 6 років тому +1

    HI naveen how do i upload image and take screen shot

    • @Linga-yp1bw
      @Linga-yp1bw 5 років тому

      For Uploading File We Need to use autoit and take screenshots we have method take screenshot mehod

  • @PreetiGupta-qz1nw
    @PreetiGupta-qz1nw 6 років тому +1

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

  • @ParasJoshiPj
    @ParasJoshiPj 5 років тому

    Naveen will it decrease our automation speef

    • @ManjunathPrabhakar
      @ManjunathPrabhakar 4 роки тому

      Yes. Culprit is thread.Sleep(). It's fine for debugging.
      However in actual production there are workaround to avoid it.

  • @techxpert7403
    @techxpert7403 4 роки тому

    I want to implement this in robot framework , please share the detailed step

  • @sagarpateldon
    @sagarpateldon 2 роки тому

    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 = element.getCssValue("backgroundColor");
    for (int i = 0; i

  • @reddy4143
    @reddy4143 3 роки тому +1

    Thank you sir

    • @reddy4143
      @reddy4143 3 роки тому

      I got job mostly your Jenkin video impressed

  • @niteshrawat576
    @niteshrawat576 6 років тому

    Hi Naveen, hope you are good.
    Will executing the script i am having an exception which says"undefined argument". I have carefully check all the code and make sure all arguments (element ,driver,color) are properly defined. Cam you please help me out with this issue.
    You can share me your email if you wanna review the code.
    Thanks in advance!!

  • @itindranil
    @itindranil 4 роки тому +1

    JavaScriptExecutor is a class or Interface ?

    • @ManjunathPrabhakar
      @ManjunathPrabhakar 4 роки тому

      Interface. Look at this www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html

  • @kushagrapandey3671
    @kushagrapandey3671 3 роки тому

    JavascripExecutor is a class or interface?

  • @nikhathk5677
    @nikhathk5677 4 роки тому

    WebElement element and Webdriver driver is giving error, please find the screenshot
    public static void flash(WebElement element, WebDriver driver){
    JavascriptExecutor js= (( JavascriptExecutor)driver) ;
    String bgcolor=element.getCssValue("backgroundColor");
    for(int i=0; i>10;i++){
    changeColor("rgb(0,200,0)", element, driver);
    changeColor(bgcolor, element, driver);
    }


    }

    public static void changeColor(String color, WebElement element, WebDriver driver) {
    JavascriptExecutor js =((JavascriptExecutor) driver);
    js.executeScript("arguments[0].style.backgroundColor = '"+color+"'", element);
    try{
    Thread.sleep(20);

    }
    catch(InterruptedException e){}

    }

  • @andreidiachenko5708
    @andreidiachenko5708 3 роки тому

    BRAVO

  • @chandrahasdhandeti8898
    @chandrahasdhandeti8898 6 років тому +1

    javascriptexecutor is a interface right

  • @megalashanmu2177
    @megalashanmu2177 5 років тому

    I am unable to implement The method executeScript, unable to pass the webelement in this.
    It says executeScript.(String, Object[]) in the type JavascriptExecutor is not applicable for the arguments (String, WebElement)
    can u help me ??

    • @JAYITAMs
      @JAYITAMs 5 років тому

      try this without creating method
      WebElement loginButton = driver.findElement(By.xpath("//input[@type='submit']"));

      JavascriptExecutor js = (JavascriptExecutor) driver;

      //Here i pass values based on css style. Yellow background color with solid red color border.
      js.executeScript("arguments[0].setAttribute('style', 'background: green; border: 2px solid yellow;');", loginButton);

  • @prashantmahajantanashah
    @prashantmahajantanashah Рік тому

    I got the following error. The browser opened but it was not able to highlight and threw the error as below:
    Exception in thread "main" java.lang.ClassCastException: class org.openqa.selenium.chrome.ChromeDriver cannot be cast to class org.htmlunit.javascript.background.JavaScriptExecutor (org.openqa.selenium.chrome.ChromeDriver and org.htmlunit.javascript.background.JavaScriptExecutor are in unnamed module of loader 'app')

    • @prashantmahajantanashah
      @prashantmahajantanashah Рік тому

      Used below methods:-
      public static void flash(WebElement element, WebDriver driver) {
      JavaScriptExecutor js = (JavaScriptExecutor)driver;
      String bgcolor=element.getCssValue("backgroundColor");
      for(int i=0;i

  • @Sifat1441
    @Sifat1441 Рік тому

    Hi Navin, JavascriptExecutor is not a class. It's an interface

  • @aryanroy9078
    @aryanroy9078 5 років тому +1

    Hi, can you please guide me to find or make xpath in ie11 for execute script in selenium

  • @davidvilla5154
    @davidvilla5154 7 років тому +1

    hI Naveen, This Pop up still interrupting to my code. not typing log in and password...

    • @naveenautomationlabs
      @naveenautomationlabs  7 років тому

      try to click on that login button using javascriptexecutor.

    • @naveenautomationlabs
      @naveenautomationlabs  7 років тому +1

      use this code to click on login button:
      JavascriptExecutor js = (JavascriptExecutor)driver;
      js.executeScript("arguments[0].click();", driver.findElement(By.xpath("//input[@type='submit']")));

    • @parvesahammed3353
      @parvesahammed3353 5 років тому

      @@naveenautomationlabs tnx

  • @shwetachoudhary1314
    @shwetachoudhary1314 3 роки тому

    javascriptexecutor is an interface and not a class, right?

  • @fahimbaig1
    @fahimbaig1 2 роки тому

    Pasting the below code
    WebElement continueBtn = driver.findElement(By.id("continue"));
    flash(continueBtn, driver);

    public static void flash(WebElement element, WebDriver driver) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    String bgcolor = element.getCssValue("backgroundColor");
    for (int i=0; i

  • @sabbirahamed1894
    @sabbirahamed1894 11 місяців тому

    How this highlight help the test or quality ? These are for new selenium users. In the real-life most important is your detailed and effective testcase. Because each additional line of coding will take time from your testing end. So, learn this but avoid using it for real-life.

    • @naveenautomationlabs
      @naveenautomationlabs  11 місяців тому

      Its not like this, you can always create a generic function and call this function in the basis of the feature flag true or false. This is useful when you want to highlight the element during the execution while giving demo or debugging.
      If you don't want to use , make the feature flag false.
      In framework it's not about test or quality, it's about adding some out of the box features to decorate the framework to understand the debugging and execution properly.

    • @sabbirahamed8554
      @sabbirahamed8554 11 місяців тому

      Naveen , I luv to watch ur videos., It's nothing related ur quality. But where you will use it in real life for what. As u know in real life we dont do show boat. In framework u have to add it as global from ur common methods, so it will run the method for all the testcases. It will add time for test running time and also it will increase testcase run failure rate. As u know selenium open source. Because it is not a part of test or it will not help u for quality. It will only help the click part for display (not the whole coverage)and we dont really need that. For display , we have limitation in selenium as u know. We can only make sure HTML & CSS and javascripts. Rest r not selenium , just java....because I m using java

  • @kalyanijoshi6884
    @kalyanijoshi6884 5 років тому

    Please share the code

  • @deepakpatil2397
    @deepakpatil2397 5 років тому

    please refer the below link to highlight the any element.
    www.softwaretestingmaterial.com/highlight-element-using-selenium/