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.
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
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?
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
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.
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
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...
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.
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.
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
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!!
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 ??
//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);
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')
use this code to click on login button: JavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("arguments[0].click();", driver.findElement(By.xpath("//input[@type='submit']")));
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.
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.
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
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
Hey Naveen, your teaching is excellent you make it so easy to understand. Really appreciate it.
Hi Naveen , are these 65 tutorials in this playlist are sufficient to crack any selenium interview ?
Yes it is
Good job Naveen, this session really help me to understand the concept of JavaScriptExecutor. Thank you so very much.
How do we implement this in framework? for each and every element i have to add this or is there any better option?
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.
Thank you so much Naveen!!🙏🙏
nice video to understand this concept. Thank yu
Hi Naveen,Please explain why driver is passed in parameter for JavascriptExecutor
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
Hi Naveen, At 8.08min You mention Javascriptexecutor as Class but its Interface
Can we achieve this by using specific XPath for multiple fields at a time and the qmetry report also shows the highlighting those fields
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?
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 ?
No It will be word and please share the code to. My what's number 6303698052
@@reddy4143 Thanks brother, but that problem I faced 2 years ago, but again thanks for your concern.
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
Worked fine for me. Thanks :)
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
This is one of the easiest way!
Can you please make a video of scrolling and performing some action like checking the check boxes randomly
Thank you
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.
I am also stuck at same the point . Kindly provide solution
Naveen can you please start online classes.. want to join some regular online class
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
Same for me. Did U find any solution
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...
Like all your videos. Thanks for sharing. One thing, do we need JavascriptExecutor object in flash class
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.
Hi how can we highlight list of web element using this
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.
Hi Naveen, thanks for the video. I am getting error as rgb(int, int, int) is not defined. Can you help?
Thanks
Please put inside quotation as shown
Hi Naveen my question is if our Application does not designed form Java Script then will JS Executor work, i think not. please answer ....
It will work.
HI naveen how do i upload image and take screen shot
For Uploading File We Need to use autoit and take screenshots we have method take screenshot mehod
Hi Naveen, Your videos are so amazing. Its easy to understand..Excellent work.
Thanks for watching it @Preeti Gupta.
Naveen will it decrease our automation speef
Yes. Culprit is thread.Sleep(). It's fine for debugging.
However in actual production there are workaround to avoid it.
I want to implement this in robot framework , please share the detailed step
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
Thank you sir
I got job mostly your Jenkin video impressed
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!!
JavaScriptExecutor is a class or Interface ?
Interface. Look at this www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/JavascriptExecutor.html
JavascripExecutor is a class or interface?
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){}
}
What is the Error
BRAVO
javascriptexecutor is a interface right
Its a class
@@sandeepredhu2035 Its an interface
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 ??
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);
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')
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
Hi Navin, JavascriptExecutor is not a class. It's an interface
Hi, can you please guide me to find or make xpath in ie11 for execute script in selenium
hI Naveen, This Pop up still interrupting to my code. not typing log in and password...
try to click on that login button using javascriptexecutor.
use this code to click on login button:
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", driver.findElement(By.xpath("//input[@type='submit']")));
@@naveenautomationlabs tnx
javascriptexecutor is an interface and not a class, right?
Right
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
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.
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.
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
Please share the code
please refer the below link to highlight the any element.
www.softwaretestingmaterial.com/highlight-element-using-selenium/