Tag Info

Hot answers tagged

37

I think it's difficult to make through-the-UI tests reliable. The challenge comes down to the difficulty of reliably controlling and observing the variables that matter to your tests. Whether this is worthwhile depends on your ability to make your test code more resilient, and on the value of being able to run the tests automatically. Asynchrony. For web ...


11

I think that Selenium functional tests are reliable enough if done right. In my opinion your fragile tests are not selenium specific but depend on how the tests are implemented. The first step to resolve this issue is finding out why most tests fail that shuldn-t fail. Timing? External Services not reachable/available? Wrong database content?


9

I +1'd Dale's answer, however I wanted to add a few additional things. Dale is absolutely correct that a large part of the fragility of automated UI tests comes from timing issues and can often be fixed by using polling (referred to as implicit waits in Selenium) or latches. I also agree with his assertions on identifying elements and depending on the ...


4

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 ...


4

You could combine the not null tests into one if statement if (Data != null || Data.SubData != null) { //Do Whatever } else { //Message Evaluation Example return Data = null ? "Data is null!" : "Data.SubData is null!"; } Above I have made a check on both Data and Data.SubData to ensure they are not null, if they are however I use a Ternary ...


4

I haven't used it, but possible it may be helpfull for you: FiddlerCore And one more alternative: BrowserMob Proxy


4

How Selenium determines whether an element exists and how it behaves when an element is not found seems to vary from one release to the next. With the current release, it is possible to finesse the problem by switching to the findElements method. For example, in Java I would do something like this: elements = driver.findElements(By.id(Element_ID")); if ...


3

Your question brings these considerations to mind: Does the component invoke the logging system at the appropriate times? This is hard to determine and impossible to determine automatically because you cannot predict where things will go wrong. It is likely that additional logging will appear as a result of bugs discovered during testing. Is the ...


3

A heavier weight solution that may net you more flexibility/control in the end is to run all your tests in a VM on your local machine. With a VM, it's fairly easy to setup snapshots so you can be sure that you're resetting your testing environment to a specific, known point every single test run. That's freakin' nice. You can minimize the VM window and ...


3

From documentation: BinaryLocation Gets or sets the location of the Chrome browser's binary executable file. So the above excerpt plainly says that the BinaryLocation is the path for chrome.exe and not chromedriver.exe. And chromedriver.exe path should be defined in the PATH environment variable. So in your case the correct line would be: ...


3

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 ...


3

Actually, I can see two questions in your post. Is it better to test SOAP Web services backed by EJB using Java or C#? Actually, Web service stack of technologies was designed to support interaction between application written in different technologies, so it does not matter how the Web service was implemented. I.e., Web service implemented in Java can by ...


3

I don't think that you should be defining the URL to the page inside the pageObject. The methods in your page object should actions/ journeys that your pageObjects can take. For example a login pageObject may have 3 methods in it: Login(String username, String password) { // fill in login form // Submit login form return new landingPage(driver); } ...


3

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 ...


3

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 ...


2

Apologies to all for duplicating this question. Turns out, that indeed, the failing script in question lives on a separate domain than the place where my error.js was being included from. So, it was indeed a cross-domain trigger of "same origin".


2

Here are some potential problems: //a[@class='wlcategoryLinkBold']/@href is an Xpath to an href, not to an "a" tag. Furthermore, //a[@class='wlcategoryLinkBold']/@href[i] is the Xpath to the i'th href of an "a" tag, which is nonsensical. I believe you want to use (//a[@class='wlcategoryLinkBold'][@href])[i]. GetSelectedLabel gets option label (visible ...


2

The WaitForPageToLoad method will not work here since Google now return results in an AJAX call when you start typing. The best practice is to wait for something knowing on the page to exist before you proceed. For example you could poll the page to check if selenium.IsTextPresent("openqa.org") is true, if it's not loop back around and try again. Just ...


2

The insertion of Thread.Sleep() is typically indicative of a race condition in your test and your test is running out of sync with the thing is it testing. One suggestion may be to insert a polling loop to wait for the redirect, or an event to indicate the redirect has happened. See http://www.testingmentor.com/imtesty/?p=652 and read the comments for ...


2

The way I handle this is to create WebDriver extensions in an IWebDriverExtensions Class so that the JQuery or Javascript methods are always available through your driver object. The driver object is cast to IjavaScriptExecutor allowing you to execute the JavaScript or Jquery. You can also create any other extension methods you need in he same class. These ...


2

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}");


2

Use profile setting for browsers: firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv"); Browser initialize FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv"); IWebDriver webDriver = new FirefoxDriver(profile);


2

Tests that explore the GUI of an application need to simulate the keyboard and mouse to send commands. They also need to read the screen to validate that the correct things are displayed. To me the mechanisms for keyboard and mouse entry and for screen reading are more important than the programming language. However as your application is in C# writing the ...


2

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 ...


2

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 ...


2

If you want every dropdown value in a List, try using this: WebElement select = driver.findElement(By.id("selection")); List<WebElement> options = select.findElements(By.tagName("option")); for (WebElement option : options) { // actions on every option, like extracting the value } Alternatively, convert your WebElement el ...


2

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 sources: ...


1

Check if the file exists and if it doesn't exist create it. If it does exist then use the same code you have to modify it. public void Driver(int row , int col, string time, string sheetName){ string sDataFile = "Ranorex_Reports.xls"; string sFilePath = Path.GetFullPath(sDataFile); string sOldvalue = "Vopak_Automation\\bin\\Debug\\" + ...


1

IWebDriver has the method WindowHandles. The method return a collection. So you can use the size of the collection to get the number of open windows. IWebDriver Interface IWebDriver.WindowHandles Property I am not so familiar with C#, but in Java this work: driver.getWindowHandle().size(); In C# should this work: Driver.WindowHandles.Count;


1

I've had great success with PhantomJS recently. The only tests that fail are those that involve javascript alerts, but that functionality should be implemented soon anyway. You can launch PhantomJS with the command phantomjs.exe --webdriver=4444 And configure selenium to use the remote web driver var hubUrl = new Uri("http://127.0.0.1:4444/wd/hub"); var ...



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