Selenium with C# 58 - How to Highlight Web element on Click & Value Change events

  Рет қаралды 2,909

Ankpro Training

Ankpro Training

Күн бұрын

#highlightelement #selenium #seleniumcsharp
What is IJavaScriptExecutor?
How to highlight the element?
Highlight elements in action globally using ElementClicking and ElementValueChanging events
Selenium with C# 57 - Capturing Selenium Events using Event Firing Web Driver class selenium events
• Selenium with C# 57 - ...
Selenium with C# 51 - IJavaScriptExecutor interface | How to execute JavaScript from Selenium
• Selenium with C# 51 - ...
What is IJavaScriptExecutor?
IJavaScriptExecutor is an Interface
It helps to execute JavaScript through Selenium WebDriver
ExecuteScript method takes variable parameters
1st parameter is the JavaScript code
2nd parameter is the element on which JavaScript has to execute
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.border='3px dotted blue'", element);
Possible Interview Questions
What is IJavaScriptExecutor?
What is EventFiringWebDriver?
How to highlight the element in action?
Code :
[TestMethod]
public void HighlightTheElementWorking()
{
IWebDriver driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "uitestpractice....";
EventFiringWebDriver eventFiringWebDriver = new EventFiringWebDriver(driver);
// Click events
eventFiringWebDriver.ElementClicking += EventFiringWebDriver_ElementClicking;
// Element Value changing events
eventFiringWebDriver.ElementValueChanging += EventFiringWebDriver_ElementValueChanging;
driver = eventFiringWebDriver;
driver.FindElement(By.LinkText("Create New")).Click();
driver.FindElement(By.Id("FirstName")).SendKeys("Tyler");
driver.FindElement(By.Id("LastName")).SendKeys("Durden");
driver.FindElement(By.Id("EnrollmentDate")).SendKeys("12/10/1999");
driver.FindElement(By.XPath("//input[@value='Create']")).Click();
driver.FindElement(By.Id("Search_Data")).SendKeys("Tyler");
driver.FindElement(By.XPath("//input[@value='Find']")).Click();
driver.Quit();
}
private void EventFiringWebDriver_ElementValueChanging(object sender, WebElementValueEventArgs e)
{
HighlightElement(e.Element, e.Driver);
}
private void EventFiringWebDriver_ElementClicking(object sender, WebElementEventArgs e)
{
HighlightElement(e.Element, e.Driver);
}
private IWebElement HighlightElement(IWebElement element, IWebDriver driver)
{
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].style.border='3px dotted blue'", element);
return element;
}

Пікірлер: 10
@AnkproTraining
@AnkproTraining 4 жыл бұрын
Thank you for watching this video. Cheers! would you mind hitting *_like_* button and *_subscribe_* to our channel! That will be awesome. We would be grateful to you. And also share this video in your circle via whatsapp, facebook and twitter.
@arabindamohanty2190
@arabindamohanty2190 2 жыл бұрын
Thanks a lot for making such an informative video. Really all your videos help me a lot. One request please develop one end-end framework. It will definitely help all of us.
@AnkproTraining
@AnkproTraining 2 жыл бұрын
As soon as possible. Thank you for watching this video. Don't forget to *_like , subscribe_* and hit that *_notification_* bell 🔔. And also share this video in your circle via *WhatsApp* , *Facebook* and *Twitter* . Link to subscribe the channel goo.gl/hFueBi
@murugappanlakshmanan2538
@murugappanlakshmanan2538 3 жыл бұрын
wonderful all your videos are very simple and answer many questions.I have one doubt how to get the location of downloaded file when downloaded in a pipleline
@AnkproTraining
@AnkproTraining 3 жыл бұрын
Thank you for watching this video. Cheers! would you mind hitting like button and subscribe to our channel! That will be awesome. We would be grateful to you. And also share this video in your circle via whatsapp, facebook and twitter.
@bhaskartimothy3146
@bhaskartimothy3146 4 жыл бұрын
Awesome sir. Using selenium with Java(JavaScriptExecutor) highlights click on text change colour is possible ?
@AnkproTraining
@AnkproTraining 4 жыл бұрын
Yes it is possible. Use EventFiringWebDriver's method. Thank you for watching this video and commenting. Cheers! would you mind hitting *_like_* button and *_subscribe_* to our channel! That will be awesome. We would be grateful to you. And also share this video in your circle via whatsapp, facebook and twitter. Link to subscribe the channel goo.gl/hFueBi
@bhaskartimothy3146
@bhaskartimothy3146 4 жыл бұрын
Tq for your reply sir..I find evenfiringwe driver in selenium Java. But using object of evenfiringw ebdriver cannot find Elementclicking method in selenium java
@kjmano100
@kjmano100 2 жыл бұрын
Background music combined with the screenshake while typing is really annoying. Remove that and you might get more views and likes
@AnkproTraining
@AnkproTraining 2 жыл бұрын
Thanks for the feedback. We experimented this, you don't see in other videos. Please like, share and subscribe.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Срочно! План США по Украине готов. Мир через силу. Прорвемся! /№897/ Швец
48:35
How to Become a Highly Employable C# Developer in 2025
20:10
Gavin Lon
Рет қаралды 5 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН