We can highlight the WebElements under action during the execution to help capture them while failure analysis.
It can be done using the below code.
Have the utility function in for framework ,use it for all the actions performed at the framework level. See the sample below.
Function to highlight the WebElement under execution:
It can be done using the below code.
Have the utility function in for framework ,use it for all the actions performed at the framework level. See the sample below.
Function to highlight the WebElement under execution:
public static void elementHighlight(WebElement element) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style',arguments[1]);,
element, "color: red; border: 3px solid red;");
}
Use it as below, used in the plain function here, you need to embed it in your framework as to highlight all the elements under action.
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver","Path to geckodriver");
driver= new FirefoxDriver();
driver.get("http://www.google.com");
WebElement searchBox = driver.findElement(By.name("q"));
elementHighlight(searchBox);
searchBox.sendKeys("Test");
WebElement searchBtn = driver.findElement(By.name("//button"));
searchBtn.click();
}
In the above example i am using Selenium 3.0.1 jars.
Note: If you are using Selenium 2.x version skip the below line from above code.
System.setProperty("webdriver.gecko.driver","Path to geckodriver");
This comment has been removed by the author.
ReplyDeleteThank you for sharing such a valuable information
ReplyDeletebest sap simple finance online training institute in hyderabad
This was really good.know about the web elements well and this coding section more useful selenium training in chennai
ReplyDeleteselenium training in velachery
After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.
ReplyDeleteJava Script online training
Share Point online training
thanks for sharing this information
ReplyDeleteaws training center in chennai
aws training in chennai
aws training institute in chennai
best angularjs training in chennai
angular js training in sholinganallur
angularjs training in chennai
azure training in chennai