Hot answers tagged

39

One of the biggest mistakes in my career was to pick a different programming language for the test automation than the development team uses. You won't get help from the development team when you have a programming issue Developers will probably not run, nor maintain tests as they change the application, you will be maintaining and analysing test results (e....


14

How to get started with Selenium: A Brief Overview So you want to automate browser-driven tests, and you're not sure where to get started. You've heard of this "Selenium" thing, and you think it's what you want, but you can't be sure. Fret not! Here's a quick rundown of what you're looking at and how to get going. This is mostly adapted from two ...


14

You can choose any language irrespective of which language is used in development. But it would be better if you go with same programming language which is used in the development, in your case it would be C#/.NET for below reasons: You can leverage existing libraries used by your team. Developers can help you out, As you said you will the only person doing ...


11

To broadly address your question, just pick some test cases with simple interactions that aren't very dynamic and automate those. Trial, error, and practice will get you there. Is Java mostly used for Selenium tests? Do you recommend it over C#? According to StackOverflow, there are more Selenium tagged questions in Java than any other language (as of ...


10

Get the table, then its rows, then each row's TDs, then each TD's anchor: var table = driver.FindElement(By.TagName("table")); var rows = table.FindElements(By.TagName("tr")); foreach (var row in rows) { var rowTds = row.FindElements(By.TagName("td")); foreach (var td in rowTds) { var a = td.FindElement(By.TagName("a")); ...


9

WaitForPageLoad() continue's after all the data for the page has been retrieved and I think when the browser OnLoad() function is called. Its possible the browser is still executing JavaScript or processing CSS. Meaning your elements might not be visible on the page just yet. Instead of waiting for the page to load you should use an explicit wait to wait ...


9

You can use a CSS Selector looking for a substring at the onclick attribute: div[onclick*='2005256'] This will look for the client regardless of the position. If you want by position: #searchpanel-clientlist li:nth-of-type(6)


9

Definetly learn C#. Why? At Selenium tests level it's basically the same thing as Java 9. With a bit of syntactic sugars. It shouldn't take you more than 2 weeks to get up to speed with C#. CI/CD and whole infrastructure is set up for dotnet. If you don't want to run this automated tests manually, you will have to either: configure whole infrastructure to ...


8

Disabling infobars is not supported anymore by Chromium. According to them, Remove --disable-infobars. This flag is no longer needed by the perf testing infrastructure and can be misused for malicious purposes, so remove it. So either you can downgrade your chrome version or start ignoring the infobar in the new version.


8

You can use the combination of any unit testing framework (like NUnit, MSTest, XUnit) with additional nuget packages for the work with REST API itself RestSharp (http://restsharp.org/) Probably the most popular and convenient REST HTTP Client for .Net. RestAssured.Net (https://github.com/lamchakchan/RestAssured.Net) .Net port of Java's lib, may be easier ...


8

Page Object and Selenium's PageFactory are distinct things in nature, usually the latter complement the former. Page Object is a design pattern aimed at solving the problem of separating the application interface from the HTML interface. Why do we separate these interfaces? Because web pages elements and functions, as saw by the user, differ from the HTML ...


7

I'm assuming you're using Firefox? Right-click the drop-down list and select "Inspect Element". Get the tag from the information (everything in green following the pound sign). Then add this to your code where you need to select the element new SelectElement(driver.FindElement(By.Id("{put your tag information here}"))).SelectByText("{State here}");


7

Quickly glanced over the properties and methods of IWebElement, doesn't look like they can set values. However, you can easily execute some javascript snippet to change HTML in your page. IWebDriver driver; IJavaScriptExecutor js = driver as IJavaScriptExecutor; js.ExecuteScript("document.getElementById("title").innerHTML = "New text!";"); You might need ...


6

NONONONONO. All above posters have it wrong. Polling and latching and what not do not account for INHERENT RANDOMNESS or SELENIUM BUGINESS . Why does a test fail and turn red in Jenkins or some other automated build? Here are the past 5 selenium failures on our build An element doesn't have a type="file". Selenium chokes sending input keys to it for ...


6

After further research, come across the following links: https://github.com/SeleniumHQ/selenium/issues/886 https://code.google.com/p/chromedriver/issues/detail?id=962 http://peter.sh/experiments/chromium-command-line-switches/ https://sites.google.com/a/chromium.org/chromedriver/capabilities Although I did not see any definitive conclusion, someone ...


6

There are three .Net wrappers for Sikuli. Personally, I was a bit disappointed in all of them. Edit: there was a small bug in SikuliSharp which was causing commands to Sikuli to fail. Now that this is working, I'm a happy SikuliSharp user. SikuliSharp: looked most promising, couldn't get it to work with the same images that worked for Sikuli4Net (see ...


6

In this context, a goal you most likely want to achieve is one of Continuous Integration (CI). To that end, from the developer side, every check-in will trigger a build (to perform certain checks and see if it passes). Then you will usually have a nightly build that gives you an up-to-date test environment every morning. Now, this pipeline should include ...


6

Your problem is with the selector indeed. Issue 1 When using XPath in the context of another element (as you are doing), always start the XPath with a dot (which represent the element you are starting from). For example, .//ul/li Issue 2 You haven't formatted your variable text into your XPath, it says {0}. So first do a string.Format on your XPath, then ...


6

Writing an API test in Visual Studio can be done with: NUnit or MSTest as your Test Runner ** NUnit and the TestAdapter are available on Nuget An http client, like .Net's HttpClient ** This is in the System.Net namespace (Optional) Json.Net for parsing responses ** Also avaiable on Nuget Your test will look something like this: [Test] public void ...


6

To add explanation to what you have already figured out. The problem was that with this line you correctly acquired the second row: IWebElement secondRow = driver.FindElement(By.CssSelector("table tr:nth-of-type(2)")); but with the next piece of code, you did not get the 4th cell of the second row, but the first 4th cell of the DOM and that starts from the ...


6

Some options in my order of preference: Probably you do not want to test the TwoFactorAuth, but you want to test the application behind it. Consider building a backdoor which is only enabled in the test environment, so that you can bypass the TFA. Generate the OTP from code with OTP.Net: https://dev.to/j_sakamoto/selenium-testing---how-to-sign-in-to-two-...


5

To play a devil advocate, if you try Python, you will find that you are substantially more productive because of dynamic typing. Python just works much harder to improve productivity of the programmer, as compared to C# which is focused to create effective code (making programmer to work harder to get it). In testing, it is of little difference if test ...


5

You should avoid doing assertions on the method's innards as much as possible, to avoid coupling the unit tests to implementation specific details. In reality, of course, that's not always possible. In this case, you don't need to verify whether those methods were called. You're gonna have to provide a mock for _emailMessageBuilder, IEmailMessage and ...


5

Start by looking for testing tasks that require a lot of manual effort and do not change from one release to the next. This is especially important for UI automation; if a web page changes frequently, you will spend so much time updating your automated test that it will have been faster to test the page by hand. Note that there are often ways to use ...


5

Below code should help you. public static class WebDriverExtensions { public static IWebElement FindElement(this IWebDriver driver, By by, int timeoutInSeconds) { if (timeoutInSeconds > 0) { var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeoutInSeconds)); return wait.Until(drv => drv....


5

Yes, you can use NUnit for functional testing. But still it is a unit-testing framework. No, you are not creating unit-tests by using a unit-testing framework to write functional tests. A unit-test is testing just a single methods input and output, by writing end-2-end tests it by definition cannot be a unit-test. :) Unit testing frameworks are often ...


5

No, technically you do not need a unit-testing framework. You could just execute Selenium steps from a C# program and write the results somewhere for you to monitor, but we use them as a runner of the tests. Since this gives standardized results which can be parsed by a continuous integration server to give you nice feedback. I would advise you to use a ...


5

StaleElementReferenceException is really common with Selenium. To avoid these issues you should be waiting for an element to load before manipulating it (clicking, sending keys, etc). This will reduce the likelihood of something between dependent actions like your click and send keys. I will typically do an explicit wait on a single or multiple related ...


5

If you are concerned about learning too much, you are doing it WRONG. The more you learn, the easier it will be for you to solve common problems. We are getting questions DAILY here which would be solved trivially by having some (very little) programming experience - which is very obviously missing. And in some cases, even willingness to learn is missing. ...


5

You are likely getting a StaleElementException. When you first get the list of elements to click, they are attached to the current DOM. After navigating away (the first time) the elements are no longer attached to the DOM (even if you navigate back). One way of getting around this is to: Get all the HREFs of the elements and store that into a list Visit ...


Only top voted, non community-wiki answers of a minimum length are eligible