Hot answers tagged

7

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


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


4

Two parts to this answer: First, to answer the question, there are many test runners. Some of them by default will run in a particular order, it may be the order they appear in code, or alphabetically, or some other order. There is often a way to tell the test runner to execute them in a particular order by providing some additional command line ...


4

I have written a blog on how to take screen shots while using webdriver APIs, This is a basic code but it will help you in taking screenshots. http://apttest.in/how-to-capture-screenshot-in-webdriver-using-java/ package screenshot_package; import java.io.File; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import ...


4

In the Selenium Simplified course the secret to the selector is really the 'value' not the 'type' as the 'value' identifies the WebElement uniquely on that page, coupled with a type 'just in case' WebElement checkBox1; WebElement checkBox3; checkBox1 = driver.findElement(By.cssSelector("input[value='cb1']")); checkBox3 = ...


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.


4

As a part of testing you should start looking into the NFRs testing like Performance, Load, Security, UX etc. testing. Study about the FRUPS+ . Performance testing too is equally important as other functional testing, as I have seen many projects to get failed/escalated to higher levels which failed to deliver good performance and Performance testing indeed ...


4

My recommendation would be to become more competent in programming, preferably in Python (excellent language for small admin tasks and generic data fiddling), and learn Linux administration with good understanding of networking. There is no limit to scaling up your skills in these areas, and neither technology will ever go away - not in your lifetime, so it ...


3

Use JUnit to handle the running of the tests from the Jenkins server. Use JDBC to query the DB for new rows. Change up the Tomcat servers so they send logging events back to the Jenkins serverJUnit test. You'll need to write a little socket listener for the JUnit test to gather the Tomcat events (Writing an LoggingEvent listener isn't hard. I'm not ...


3

The answer provided by Sam nearly worked for me, but still had some problems as described above. Basically I needed to use TestRule instead of MethodRule, and TestWatcher() instead of TestWatchman() - since the former ones have been depreciated. I also needed to pass in "Description" instead of "FrameworkMethod" to get the name. Finally I need to ...


3

You can use the TestWatchman class which is part of JUnit to get the test case name, as well as the status, so you could take screenshots only on failure. Here's an example that takes a screenshot on failure: @Rule MethodRule watchman = new TestWatchman(){ @Override public void failed(Throwable e, FrameworkMethod method){ File scrFile = ...


3

It should be as easy as: IWebElement element = driver.findElement(By.xpath("//input[@type='checkbox']")); if (!element.Selected) { element.Click(); }


3

If I understand the question, the issue is not so much about parallelized tests as it is about the JUnit runner's policy of reporting failures individually but only reporting successes in aggregate. If you want successes to be reported individually, I suggest you register a custom RunListener. The RunListener will be invoked each time an event occurs ...


3

Hm. Did I understand correctly that you are indeed receiving a timeoutexception? Could you provide any stacktrace? "I know the element is in the DOM as it will pass more often that not. So if I was to run this overnight, it could fail when it would pass 9 times out of 10." This statement is not good enough. The best you can say is that you can ...


2

I am not sure how to do it manually, but there's a testing framework (thucydides) that can do what you need: http://www.thucydides.info/ This tool in fact integrates Selenium Webdriver with other tools to make your life easier. You can setup a test maven project quite fast. Since it is open-source, you could check how they capture the screenshots if you ...


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

For backend coverage (mostly java), we use Cobertura: http://cobertura.github.io/cobertura/ The developers tend to use Emma, in Eclipse: http://emma.sourceforge.net/ For frontend (JavaScript), I've heard good things about ScriptCover: http://googletesting.blogspot.com/2011/10/scriptcover-makes-javascript-coverage.html Good luck!


2

There is no default provisioning in JUnit to do this the way you want. By using MethodSorters.NAME_ASCENDING you can ensure order by naming tests in alphabetical order as showed in other answer. Alternatively, you can create your own OrderedRunner and an annotation to fix this type of ordering. public class OrderedRunner extends BlockJUnit4ClassRunner { ...


2

If the element you are interacting with is being replaced in the DOM, which appears to be the case since you're getting a stale element exception, you'll need to find the element again rather than re-using the existing one. So for example, you would do this: chrome.findElements(By.tagName("option")).get(0).click(); ...


2

After some good experience in manual testing , It is always good to move for automation. Please start with following tools for automation testing : 1 - Selenium web driver Selenium support many programming languages like Java , c# , Python and some others also. It will help you to do automation testing for functionalists. For ex: Login , Register in ...


2

MultiScreenShot I found following useful link in Github for Multiscreenshot


2

Three possibilities: The IDE inputs (e.g. arguments and environment variables) are not the same as the command line inputs. You can check that with print statements or logging. The libraries are not the same. I assume you know how to check this. You found a timing problem. To check this, first determine which element is erroring out, then try waiting ...


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

@siva prasad: Did you use wait in your script?, if not please use below code may solve your problem. If not please paste your code so we can look into it. driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);


2

@Django_Tester: If you want to use your set of data such as usernames, passwords, default url, etc in one class and calling these data into another class, then store your data in a string. String un = "s"; String pwd = "s"; String baseurl = "your test url"; And below is the sample code: import java.util.concurrent.TimeUnit; import org.junit.*; import ...


2

The size() function returns the number of elements found with the getElements() function, I expect it to return just one table element. The value of size equals 1. I would get the HTML inside the table and count the occurrences of <tr> or something unique per row, expecting you do not have nested tables with rows inside the initial table. The code for ...


2

Hello since you are getting the results in the List, you can export them to a file for use in future, or can use them further for comparison or whatever you need since the data is already stored in the List variable. You can see in this sample code here - http://milinpatel17.wordpress.com/2014/07/02/web-page-link-test-using-selenium-webdriver/ that I have ...


2

I think the same scenario could happen even if class A uses class B but does not contain class B. One way to mitigate that risk is to write unit tests for class B that validate the assumptions embedded in your mock.


2

I am currently at the same point. I work for 3 years in QA. I strongly believe that if you have mastered the job you are currently doing in your present position you should consider expanding your knowledge in fields closely related to QA. My opinion is that it does not really matter if you use Selenium and then learn Robot Framework, and then Watir or ...


2

From my point of view it makes sense to dig into the next areas: Performance Testing. There are some good free and open source tools, you can choose one and master it. Don't try to learn the specifics of them all, creating and running a performance test is easier and lesser part of the process, the main point is results analysis, bottlenecks and saturation ...



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