Tag Info

Hot answers tagged

6

Selenium is a tool that remote-controls a browser. You can use it to simulate a user interacting with a web site. JUnit is a framework for writing Java unit tests. It takes some of the grunt work out of organizing tests and generating reports. You can express each test as a method on a class; typically, you have multiple tests per class. JUnit will run ...


6

Java My experience is, that the basics of Java suffice to start developing test cases with Selenium 2 / WebDriver. Myself started developing of Selenium test cases with a basic knowledge about Java. The more test cases I wrote and solutions I had to find, the more I leaned about the programming language. Unit Testing Framework (JUnit, TestNG) Write some ...


4

Take the screenshot in the @After test tear down method, which is run after every test. This way you will always get a screenshot for both passed and failed tests. public class TestSample { static WebDriver driver; @Before public void setUp() { //start new webdriver session, for eg using firefox driver = new FirefoxDriver(); ...


4

Not everyone on the team needs the same skills, and if you already have enough development capacity you might be more valuable for the overall results if you take up other tasks. When working together with testers in an automation project, developers can focus on the development part if there is someone else who: Really understands the application and the ...


4

If your using Java, here is the JavaDoc If your using Ruby, here is the Ruby Docs If your using Python, here is the Python Docs If your using .Net, here is the .Net docs This will contain all of the functions that Selenium uses.


4

You can use the findElements method to find all TD tags that match your criteria, and then getText method to retrieve each element's value. The latter will be returned as a String, so you may need to convert it to a number before comparing it. Since the sorted elements have a special class, you may want to use a CSS selector with findElements.


3

I don't see why this couldn't be done if you have a code driven Selenium test suite. You would need to implement a method run on test failure that adds a bug to Bugzilla using their HTTP REST API. For the first step, if you are using Java, see this answer on taking a screenshot when selenium fails and the referenced blog post. You need to similarily ...


3

Depending on your project you may also assert visual consistency, for example in a website that shows breadcrumbs the level of nesting should be consistent with the displayed breadcrumbs. Maybe a 'minimum width' for buttons/text inputs/etc. You may also probe performance and measure how fast is the site loading. Whether these are expected of you or not is ...


3

I understand you have problems with test automation because you are not much skilled (yet) in programming. And it hurts. I believe the more something hurts, the more resistance something offers, the more you need to practice that until the moment things become a routine for you and you become more effective. There are no workarounds and shortcuts to master ...


3

No, Selenium 2 / WebDriver is for web applications only. But there are other tools to automate desktop application GUI tests. http://en.wikipedia.org/wiki/List_of_GUI_testing_tools You can also search for "desktop application" on this site to find recommended tools.


3

Some people may prefer to use a new Driver instance for every test in order to avoid one test's side-effects from impacting another test. I have never run into that problem. For efficiency reasons, I try to re-use a single Driver for all tests in a suite.


3

Well the reason you are getting so many different matched is because you print it as you go through the loop. My personal suggestion, I like the KISS method, change the code to something like the following: public class Ex1 { private WebDriver d; @Test public void testUntitled() throws Exception { d = new FirefoxDriver(); ...


3

type void type(java.lang.String locator, java.lang.String value) Sets the value of an input field, as though you typed it in. Inputs the value. Sets the textfield to the value, nothing special. It just takes the entire string and puts it in there at one time. typeKeys void typeKeys(java.lang.String locator, java.lang.String value) ...


3

You can use the following code also to handle popup. String mainwindow = driver.getWindowHandle(); for (String popup : driver.getWindowHandles()){ driver.switchTo().window(popup); } // Your code on poppup window driver.switchTo().window(mainwindow); //Switching to main/parent window Hope this will help :)


3

For testing it, your doing an extremely basic test. A major advantage of automation is that you can do a lot more testing. I would set up a datasource for names, declare them valid or invalid, and have it attempt to use it. I would also have it only use one of the special characters at a time and the rest be valid (As of now your essentially testing if any ...


3

The actual slider is a link-element you should be able to define a css selector based on its classes. <a class="ui-slider-handle ui-state-default ui-corner-all" href="#"></a> The first you find is the left slider, the second the right slider. I have successfully used use the Action Builder and the MoveToOffsetAction to drag a slider X number ...


3

You mean to say in one class multiple methods you want to run, then use below code and try. @BeforeTest public static void beforeMethod() { driver= new FirefoxDriver(); } @Test public void main1() { driver.get("http://indianrail.gov.in/pnr_Enq.html"); driver.findElement(By.id("element")).sendKeys("1234567890"); String ...


2

CSS selectors can also match strings that start with, end with, or contain a certain substring. For example input[id^="E_DOS_TITEL"] will match an input element whose id attribute starts with the text E_DOS_TITEL. The ends with comparison operator is $=, and contains is *=. The example provided above should work as long as it's the only input element ...


2

I know you can do this using Appium and launching the Chrome browser app. The set up is quite a bit more then selenium AndroidDriver. I have gotten pretty close to doing it. If your developing on windows, one hurdle is the framework seems to be written and maintained by all Mac users so the windows support and documentation is quite scarce. Also you will ...


2

You didn't say whether you were using Ant or something else. I will assume you are more interested in the "positive and negative" part of the question than how to invoke the JUnit test runner from your build tool. You can register a TestWatcher to monitor what happens during a test run. The JUnit test runner will invoke methods on the TestWatcher when ...


2

If you can't determine why the browser won't launch, you can make your tests more robust. Make sure to clean the environment during test warmup, add some retry/wait/timeout wrappers around the section that launches the browser, and kill any processes and services that aren't relevant to the test. In order to find out why the browser is crashing, you can ...


2

Try using SIkuli it can automate anything , since it uses Image recognition http://www.sikuli.org/


2

Agree with User246 and here is an example of how to do: protected WebDriver getWebDriver() { if (driver == null) { driver = new InternetExplorerDriver(); } return driver; }


2

Create function AdminLogin Create into each test class method SetUp (doc) Call admin_login by SetUp Looks like: protected function setUp() { AdminLogin(); } This method calls before each test into test class Good luck!


2

To add to gomesr's answer, you might find yourself needing to wait for other elements during your tests. One way to easily have reusable code for this is to use a closure (also known as an anonymous function or a lambda function) to create a spinner function that you can call whenever you're waiting for an element to load. The spinner function would look ...


2

If this is a Javascript alert box, this is relatively straightforward; you can switch to it with driver.switchTo().alert(); in Java. If you save the return value of that as an Alert object, you can interact with it, like alert.accept(). See the javadoc for more information. Since you're asking, however, I suspect it's not so simple. If this is not really an ...


2

Both Saucelabs and TestingBot provide a service which records your Selenium tests if you run them against their Selenium Grid. Both offer a number of free minutes per month, which might suffice your needs. You can view/download the video's straight after the test run is finished. Although I don't know how their setup works, I think I can give you some ...


2

I've found in the past that using a BDD framework like SpecFlow helped me with this. You can start off writing the tests, and slowly start writing the code for it each of the tests as your able to. SpecFlow is great for code re-use, although, it can take some getting used to. An example of this is every time you use "And log in to the application", the ...


2

Your nice list covers all of the usual bases. Another possibility: Implement some sort of "critical region" mechanism around the individual pieces of data that are shared among tests, and that different tests require to have different values. This creates its own problems, of course. It causes one test to block while waiting for another to finish with ...


2

You can try setting implicit wait time. (Documentation) // 5 seconds implicit wait (C# code) IWebDriver driver = new FirefoxDriver(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));



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