Tag Info

Hot answers tagged

31

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


10

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

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


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

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


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

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

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

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


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

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

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


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

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

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


1

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


1

As Lyndon said, you can use Selenium 2/Webdriver for desktop applications, although to do this you have to compile in the web driver (caveat: I don't know any more about it than this). Some other alternatives based on the information in your question: You can use NUnit with Microsoft's unit test framework for both web and desktop applications. I don't know ...


1

One stable and fairly inexpensive option is to use a service like Sauce Labs https://saucelabs.com which allows you to run your tests on a grid that they maintain and has a bunch of browser versions and OS versions that you can target with your testing. There are some other perks like there is a video of each test that ran that you can go and watch later, ...


1

The issue I had is that the HtmlUnit driver requires works a bit differently than the FireFox, Chrome or InternetExplorerDriver. Those drivers will get started by the application that is calling them. For this I actually had to start the stand alone server on my box. This was accomplished simply by navigating to the directory that contains the stand alone ...


1

"Target machine Actively refused it" means that the host sent a reset instead of ack when you tried to connect. There is no problem with your code . Either there is a firewall blocking the connection or the process that is hosting the service is not listening on that port, this may be because it is not running at all or because it is listening on a different ...


1

I have a somewhat similar setup, however we decouple our non unit tests (Anything requiring an install to a server) from the typical unit tests which can run directly on the team city build server. In my solution we created a windows service polling team city for new builds via the rest API and when we find a new build we add it to the queue to execute our ...


1

I have no way of testing this and if I had sufficient rep would make this a comment but I don't so... Have you tried sending .Build().Perform() before the key up commands? Actions builder = new Actions(this.driver); builder.KeyDown(Keys.LeftControl); builder.KeyDown(Keys.LeftAlt); builder.DoubleClick(BrowserHelper.GetElement(this.driver, locator, ...


1

You may be able to do this by setting driver-specific settings. For instance, let's say you're using Chrome. When you fire up the Chrome driver, you can set Chrome options like so: DesiredCapabilities capabilities = DesiredCapabilities.Chrome(); capabilities.SetCapability("chrome.switches", new List<String>() { "--start-maximized", ...


1

The answer to almost all questions about unit testing is "decouple from dependencies". Refactor your code to decouple the logic (which you want to test) from the interactions with with Excel. Remember that unit tests should answer the question "does the code I am writing do what I intend it to do" and not "does my program work properly" - that's for ...


1

I haven't done this type of testing, what I would recommend is looking into how you can write office macros that utilise the functions of your add-in to test it's functionality. You should be able to add vba command buttons to a spreadsheet or document or the word toolbar that runs your tests. I am assuming that as you are testing and adding in VSTO, you ...


1

Try [SetUp] public void SetupTest() { FirefoxProfile SeleniumProf = new FirefoxProfile(@"C:\location of your custom profile"); driver = new FirefoxDriver(SeleniumProf); } You don't need to declare the binary. It works for me and I'm using FireFox 9 on Windows 7



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