Skip to main content

Posts

Showing posts from May, 2017

How to delete a component in Selenium using java

Sometimes we want to delete a component that we don't needed in order to automate the application. Below is the code that will work for you.   For further queries or any suggestions from your side are most welcome. Thanks! JavascriptExecutor js = null;         if (driver instanceof JavascriptExecutor) {             js = (JavascriptExecutor) driver;         }         js.executeScript("return document.getElementById('ID of a Component which you want to delete').remove();");  

Program to find most recent file in a folder

Below is the function used to find the most recent or last modified file in a directory. Try it and see the result. Enjoy!!! public File getTheNewestFile(String filePath, String ext) {                    File theNewestFile = null;                    File dir = new File(filePath);                    FileFilter fileFilter = new WildcardFileFilter("*." + ext);                    File[] files = dir.listFiles(fileFilter);                    if (files.length > 0) {                        /** The newest file comes first **/        ...