Hot answers tagged selenium2
11
I find the Page Object pattern very useful, and use a modified PageFactory (parameterized for custom timeouts).
I also use WidgetObjects (basically, PageObjects with a parent reference via constructor) to represent common themes across pages.
I don't think URL association is necessary on all pages, so I keep it out of my base class. URL params? I keep ...
8
You can capture network traffic using a proxy, such as the BrowserMob Proxy (http://proxy.browsermob.com)
To configure the use of the proxy with a webdriver instance, set the CapabilityName.PROXY value to a org.openqa.selenium.Proxy instance:
Proxy proxy = new Proxy();
// The URL here is the URL that the browsermob proxy is using
...
8
If you can, try & promote the idea of test first development (aka TDD, BDD, ATDD, Specification By Example) with Continuous Integration (frequent commits to a pipeline such as Hudson or GO from Thoughtworks which continuously runs the automated checks to see if any of them have broken after a recent commit)
Before Developers write the code, they write ...
7
The class you are looking for is the WebDriverWait class that you can find here (C#):
http://code.google.com/p/selenium/source/browse/trunk/dotnet/src/WebDriver.Support/UI/WebDriverWait.cs
I created an extension method to make it easier to use that looks something like this:
public static class BrowserExtensions
{
public static T ...
7
Link to my blog where I discuss this in more detail.
First of all why do you want to download the file? Are you going to do anything with it?
The majority of poeple who want to download files just do it so that they can show an automation framework downloading files because it makes somebody non-technical ooo and ahh.
You can check the header response ...
7
The default WebDriver setting for timeouts is never. WebDriver will sit there forever waiting for the page to load.
The following timeouts are available:
/**
* An interface for managing timeout behavior for WebDriver instances.
*/
interface Timeouts {
/**
* Specifies the amount of time the driver should wait when searching for an ...
7
I suspect this is not a TestNG issue. I would start by trying to produce a minimal set of tests that, when run together, cause failures. After that, I would explore these possibilities:
Inter-test interaction changes test-application interaction: It is possible that interaction between your tests changes how your test interactions with your application. ...
7
These days, I'd say Selenium RC is not worth learning unless you have a specific need for it--for example, to work with legacy test code that uses it.
I don't think it will give you a significantly better appreciation of the Selenium architecture. You can get that by exploring the Selenium code base if you have an interest.
If you the know WebDriver API ...
6
SeleneseTestCase is deprecated and shouldn't be used any more, use extends SeleneseTestBase instead.
5
I wouldn't use the WebDriverBackedSelenium class at all. It's designed to be a bridge class to help people migrate there tests using the Selenium RC API (on which very little work is being done) to the Selenium WebDriver API. Rather, I'd use the techniques the WebDriverBackedSelenium class uses in my own tests.
In the case of asserting that an element ...
5
I am actually not entirely sure you can switch to a window not spawned by the driver. I think the people working on the selenium 2 project have worked a little bit on switching to a window spawned by a different driver. When you do:
driver.getWindowHandles()
All you get are the windows spawned by the driver object it is called on.
5
While I'm not certain if these mechanisms will specifically work with the Telerik controls (I know it works with jQuery), there are a couple of ways to do this. You can use IRenderedWebElement.DragAndDropOn(), but this method is deprecated. The newer way, which isn't available in a released binary form yet, but is checked into the source tree and will be ...
5
There's a couple of solutions depending on how your particular company is set up. The easiest is if the machine that you're running the tests from is on the same domain as the server where the site is hosted. Have the team that manages the server to create a self-signed certificate and have the cert added to your machine.
If the self-signed route doesn't ...
5
I assume that you are not using stand-alone jar of selenium.
Can you download Selenium Server Standalone jar
and use it in eclipse. This is the only jar you need from selenium-java as it encompasses all required class files. You can remove other Selenium related jars from your eclipse.
4
No there is no native solution at the moment. If you use webDriverBackedSelenium you can try to utilise the captureNetworkTraffic functionality, however there were issues with it last time I heard it talked about (See here for more info - https://groups.google.com/d/topic/selenium-users/fMSHeH9ZVqU/discussion).
It's also worth noting that ...
4
This sounds similar to a problem I dealt with recently using watir-webdriver (which, if you're using webdriver will be similar). In my case I was able to resolve/ workaround by sending a click at the element (to select it) before using sendKeys. So I suggest you could try sending a click to the element before using sendKeys. :)
4
Don't forget the not only performance is better with CSS locators, it's the compatibility too that matters.
We are testing on a multy browser environment in which we use: IE, SAFARI, FIREFOX, CHROME.
On IE the xpath almost never works OR it is SO slow that it can't be managed. So we use CSS where ever we can. Unfortunately IE does not support many CSS ...
4
I suspect your browser asks you to accept xyz.com's certificate because the certificate is self-signed. There are ways to work around the problem, but they are browser-specific, and you did not mention which browser you used.
Some options for Firefox include:
Configuring the browser to accept all certificates. I do not recommend doing this unless your ...
4
We sometimes have problems like this. I have found the easiest way to solve this is to use a wait function. I imagine that when the page is loaded the button is hidden and there is javascript to make it visible. Often times the driver will run faster than the javascript.
EDIT:
elem = self.web.find_element_by_id('tos_agree')
driver = self.web
elem_visible ...
4
I'd recommend seriously looking at building a framework that has the absolute minimum of repeated script code - this has the advantage of minimising update work. Similarly, I'd consider data-driven scripts with an object-oriented framwork where you're building your transaction objects to harness the application's features.
That way, as the application ...
4
One option is HTMLUnit which is headless but has its own proprietry JavaScript rendering engine so it is possible that it will behave differently to existing browsers (If you do use HTMLUnit don't forget to enable JavaScript when you instantiate it).
The second option is to use XVFB, this will run the tests in a virtual frame buffer environemt. This has ...
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 can find only children of an element like this:
IWebElement parent = FindElement(...); //However you want to find the element
IWebElement childDivs = parent.FindElements(By.XPath("div"));
This would find you all child div's of that parent element, you can adjust the xpath to get you whatever you want.
If you already have the child and you want to ...
4
Selenium Web Driver does not necessarily integrate with an IDE the way that many people think it would. All that selenium is is a library. Import this library the way that you would any other in your code and in Eclipse, and it should work just fine.
I'm not sure if this answers what you were looking for?
4
Blobinator, welcome to SQA.
For the purposes of your question, it may help to think of a UI test as two overlapping activities: interacting (e.g. clicking/typing) and verifying (confirming that the site behaves correctly). Interacting and verifying overlap because it may not be possible to interact in the way you intended unless the site behaves correctly. ...
4
Quite simply No!
WebDriver was a project in its own right before it merged with Selenium so looking at the Selenium RC codebase and API is not going to give you any insight as to why certain decisions were made inside WebDriver.
Selenium RC is currently deprecated, so if you do start learning it you are learning something that is no longer supported and ...
4
In your comment you mentioned that the element is within a <frameset> \ <frame>. To work with any element within a frame, you need to first switch the context of the driver from the main page to that frame:
driver.switchTo().frame("foo");
In this example "foo" would be the name of the iframe. You can also do it by index if the frame has no name ...
3
If you are only using HtmlUnitDriver because you don't have a screen, just run the test with the firefox driver and run it headless. In case you are not familiar with headless it is as simple as running Xvfb :1 -ac -screen 0 1024x768x24; export DISPLAY=:1 We use headless firefox selenium tests on a hudson server that doesnt have a screen. Works fine for ...
3
I appreciate the value of being able to run tests on a machine that does not have a desktop. However, I have never been successful at getting a test that works with a real browser to also work with HtmlUnitDriver. I would be reluctant to draw any conclusions about the quality of a web application based on the results of running an HtmlUnitDriver-based ...
3
A possibly more generic solution to this problem is to wait for the jquery to complete. You can do this with a function like this:
public void WaitForAjax()
{
while (true) // Handle timeout somewhere
{
var ajaxIsComplete = (bool)(driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
if (ajaxIsComplete)
...
Only top voted, non community-wiki answers of a minimum length are eligible
