JavaScriptExecutor
JavaSciptExecutor is an interface which provides mechanism to execute Javascript through selenium driver. JavaScriptExecutor is used when Selenium Webdriver fails to click on any element due to some issue. JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript(Script,Arguments); // to enter text js.executeScript ("document.getElementsByName('uploadfile_0')[0].value='C://Users/ankumalv/Desktop/testNotes.txt'"); // to click js.executeScript("arguments[0].click();", spaceIsAWebelement); js.executeScript("alert('Hello world - this is ankur');"); // to get docs String url = js.executeScript("return document.URL;").toString(); js.executeScript("return document.title;").toString(); //toscroll js.executeScript("window.scrollBy(0,600)"); And below simple prog to upload a file: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebE...