Upload file or image using Selenium Webdriver in C#

Here is the code that you can use to Upload file or image using Selenium Webdriver in C# IJavaScriptExecutor js = driver as IJavaScriptExecutor; js.ExecuteScript(“document.getElementsByName(‘userfile’)[0].style.display=’block';”); IWebElement element = driver.FindElement(By.Name(“userfile”)); element.SendKeys(“image file path”);

Example of verifyTextPresent in Webdriver

Here is another example which takes in a WebElement and searches the text of elements with particular tags public boolean verifyTextPresent(WebElement rootElement, String tag, String text) { List elements = rootElement.findElements(By.tagName(tag)); boolean match = false; for (WebElement elem : elements){ String elementText = elem.getText(); if (elementText.contains(text)){ match = true; break; } } try { Assert.assertTrue(match); […]

Selenium the Agile automation testing tool

Test automation is usually lagging behind development of new functionality. The tools that are used to automate are dependent on the UI and this causes automation of the functionality to start only after the environment and the UI are stable. Selenium is the test automation tool that helps test below the UI layer. The automation […]