Hot answers tagged

10

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use. TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc... Additional Features: Annotations. Run your tests in arbitrarily big thread pools with various policies ...


10

Use a mock. Mock 3rd party API using MockServer or WireMock, if you're in the Java world. Your test will call getNumUsers() method which in turn will call mock of your 3rd API and the mock will simulate returning HTTP 404 response back to the getNumerUsers(). Then your test will verify if the method can handle the 404 response, e.g., whether it throws ...


9

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


9

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 = driver.findElement(By.cssSelector("...


8

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


7

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


6

Starting from your first question: Your answer did not give the interviewers any indication that you understand the technology challenges behind your automation suite. They were expecting answers that would cover possible technical solutions like: Changing from a full browser to a headless browser stack Optimizing code to reduce inefficiencies Removing ...


6

You don't need to add any additional dependency. Start doing some preparatory refactoring in order to: Program to an interface instead of a concrete object; Break the getNumUsers() into two functions, one to fetch the data itself and another to extract the data from the DTO. Then you can implement a stub which simulates the 404 return value. (As a side-...


5

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


5

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


4

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


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. package screenshot_package; import java.io.File; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; ...


4

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


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


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

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


4

How do you reduce the time of your regression suite? This may depend on what technologies the regression suite is based on. There can be technology/tool specific optimizations, like using faster database drivers, test runners, language/interpreter optimizations, or, as @siutex mentioned use Explicit Waits instead of hardcoded time delays, which tend to wait ...


4

As it seems to me, the most close equivalent to JUnit assertion messages is withMessage() method introduced in FluentWait class. Below is the example of how I use it: public class Test { public static void main(String[] args) { String[] paths = new String[]{ // Set proper and improper paths as an example of input "//img[@alt='Google'...


4

Selenium is a tool that remote-controls a browser, You can use it to simulate a user interacting with a web site. for more info go through Selenium JUnit is a unit testing framework for writing Java unit tests.for more info go through Junit


4

Selenium WebDriver is a tool using which we can automate any web application. It can open a browser, launch a URL, write on a text box, click buttons, etc. In short, it can simulate user actions. But in order to test something, we need to have a tool that can provide us methods to pass-fail a test case based on the different validations, organise the test ...


3

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


3

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


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

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

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


3

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


3

I think the answer to your question depends on what the exception text string is going to be used for. Is it part of the documented interface for that class? If some other part of the program is going to use it (say to pass that error message back to the person entering the data), and/or it's part of the documented interface, then you absolutely need to ...


3

If 'ID' of your webElement changes everytime after refreshing the page in this situation: First of all look for any other attribute which Is not changing every time In that div node like name, class etc. Option 1: If this div node has class, name attribute then you can write XPath as below. //input[@class='fld'] OR //input[@type='text'][@class='fld'] OR /...


3

I can't think of a developer writing a method which takes 25 arguments. This is a terrible design. Practically your method should not take more than 3 arguments. OK, coming to a solution, in case you encounter something terrible like this; how to test it: Ask the developer to refactor that method so that it becomes testable. I'm not kidding. Instead of ...


3

If refactoring is not an option then try to see this big function as a class of methods and focus on individual parts of this function which themselves are a logical entity, and design parameters values accordingly keeping all the other irrelevant parameters values as static.


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