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


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

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

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


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

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

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

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

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

I think the issue here might be in your recursive call to IterateOverReqs. You pass in the parameter tn which is the top node, therefore, all your requirements are being added to that top node. Instead, you should pass in the t node so that lower level requirements are added to the node just above it instead of the top node. private void ...


1

I would have small sleeps (say 100ms) between each keystrokes. This far more human like then the speed in which Selenium can enter text. Quite often the auto suggest mechanism may be triggered by delays between keystrokes, and entering quickly via selenium may not trigger.


1

A little hacky, but might work: You do the SendKeys(), and then wait with a WebDriverWait. I don't really know the C# syntax, but should be similar: (new WebDriverWait(yourdriver, 10)).until(visibilityOf(theDropdownWebelement)); This would throw a TimeoutException after 10 seconds of not finding the dropdown. Having wrapped all the process in a method, you ...


1

Such Intermittent faults are the hardest ones to debug. What I would like to suggest is to look around: Run tests under Fiddler. This tool may help you to find http requests with errors. Also, it would be helpful to find the request which gets the suggestion list and reissue it several times (there is an option in context menu – reissue request.) When ...


1

I am trying a mock that uses an Object List of return values as a queue. Every time my mock is supposed to return something, it first looks in the queue to see if I've queued anything, and if so, returns it. Then I implemented an additional Queue method for my mock that I can call during test setup that just adds items to the List in the order I want them ...


1

Can you instantiate you selenium object as ? selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.com/"); Here *chrome refers to firefox browser and has elevated security privileges on java script security restrictions.


1

Sounds like an odd bug, I thought the window handle used to be a hash like object and you could use either the handle or the title of the window to switch to and from but that might have changed since the last time I saw it. If you want both windows to have the same name you could use the driver to execute JavaScript that will grab the element creating the ...


1

If the popup window is generated by execution of javascript on the parent window, there used to be an issue with Selenium that it would not identify the newly generated window. If you haven't tried, the first thing I would do is check that the Selenium / WebDriver even knows that a second window exists.


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



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