How do I use Selenium in C#?

From the Selenium Documentation: using OpenQA.Selenium.Firefox; using OpenQA.Selenium; class GoogleSuggest { static void Main(string[] args) { IWebDriver driver = new FirefoxDriver(); //Notice navigation is slightly different than the Java version //This is because ‘get’ is a keyword in C# driver.Navigate().GoToUrl(“http://www.google.com/”); IWebElement query = driver.FindElement(By.Name(“q”)); query.SendKeys(“Cheese”); System.Console.WriteLine(“Page title is: ” + driver.Title); driver.Quit(); } }

How to get the text from the HTML5 input field error message in Selenium?

The Selenium API doesn’t support directly a required field. However, you can easily get the state and the message with a piece of JavaScript (Java): JavascriptExecutor js = (JavascriptExecutor)driver; WebElement field = driver.findElement(By.name(“email”)); Boolean is_valid = (Boolean)js.executeScript(“return arguments[0].checkValidity();”, field); String message = (String)js.executeScript(“return arguments[0].validationMessage;”, field); Note that it’s also possible to use getAttribute to get … Read more

Cypress get href attribute

The code below should do what you’re trying to achieve. There is also an entire recipe with suggestions on how to test links that open in new tabs. it(‘Advertise link should refer to Contact page’, () => { cy.get(‘div.footer-nav > ul > li:nth-child(2) > a’) .should(‘have.attr’, ‘href’).and(‘include’, ‘contact’) .then((href) => { cy.visit(href) }) }) I … Read more

How to upload a file in Selenium with no text box

Unfortunately, you can’t do that as of now (January 2013, Selenium 2.29.1), because Selenium doesn’t support <input type=”file” multiple> elements. There is a feature enhancement request for this made by the project developers themselves, it’s just not yet implemented. You can star it there to move it upwards in the priority list. Also, as far … Read more