Hot answers tagged

9

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


5

I have used Selenium and TestNG in the past to manage a lot of my automation and as Siva mentioned you do have the basics down. While TestNG is one of the most common Frameworks out there, it is not the only one, and you can use whatever one works for you. So long as you can import the Selenium drivers you can use any framework in which you are familiar, ...


4

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


3

TestNG has a feature called soft assert. This kind of assert doesn't stop the test when assert is failing. First initialize it: import org.testng.asserts.Assertion; import org.testng.asserts.SoftAssert; public class MyTest { private SoftAssert softAssert = new SoftAssert(); } Then use it in your test: @Test(dataProvider = "getMailUrl") public void ...


3

The best way is to separate out the details of the WebElement and methods to do with clicking on it, into separate classes - keeping a separation between the code which directly interacts with the UI and the code which does the testing logic. This is a design pattern called the Page Object Model, and your code will end up looking a bit like this: package ...


3

What type of machine are you running it on? Most likely it has nothing to do with TestNG having any type of thread limits (I couldn't find anything saying there were in fact limits) but rather your local box. Thread count limits on Windows or Linux are determined by the stack space. Explanations can be found here and here. On Windows the default stack size ...


3

I can see multiple solutions: Parse HTML page you test, e.g., with some XML+XPath+JSoup libraries, and check whether element you selected has a right link. This will not work with XHR/AJAX requests, that are sent with JavaScript. Click the element you want, e.g., with Selenium Web Driver, and capture the HTTP traffic with HTTP proxy, e.g., BrowserMob ...


3

XL Testview Have a look at XL Testview from XebiaLabs. Test analytics and decision support that spans testing tools See all your test results in one single dashboard Analyze test results across multiple test tools Track release metrics and quality trends over time Use real-time quality data to make the best go/no-go release decisions ...


2

I don't quite get why you would like to share browser session. UI test methods should be run in the own independent browser. In case you insist, you could use @BeforeClass of TestNG and have driver set up done in @BeforeClass method. Now both of your methods should be either in this class or class with extends the set up class. Confused? This might help - ...


2

you can pass the driver as argument to the methods , so no need to re create them.


2

Place this in your test or suite tag: preserve-order="false" If this is not in there, parallel classes will not work.


2

Please use below xml file and from command prompt go to project location and run as "ant generateReport" (Should have ANT). Let me know if you have any questions. .xml file: <project name="TestAutomation" basedir="."> <property name="LIB" value="${basedir}/lib" /> <property name="BIN" value="${basedir}/bin" /> <path ...


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

You are comparing values, so better you store each values in the String and compare both the String values.


2

You can go either way. You might include these steps in each test, because they're actions that an actual user will take. Meaning that they can potentially fail in specific circumstances, and thus you'll want them linked to that specific test case. However, signIn() and signOut() look like actions every tester will perform manually as well for every ...


2

TestNG has been created as an alternative to JUnit in unit testing. While, RobotFramework has been created for acceptance testing. Each has remarkable features: TestNG TestNG is easily integrated into maven cycle and used mostly with Data Driven testing TestNG is pure Java Annotations are easier to understand Test cases can be grouped more easily ...


2

Slightly different approach, this worked for me @AfterMethod public void writeResult(ITestResult result) { try { if(result.getStatus() == ITestResult.SUCCESS) { //Do your excel writing stuff here } else if(result.getStatus() == ITestResult.FAILURE) { ...


2

Yes, it can be done. Parameter passing in TestNG can be done two ways: Using @Parameter tag and you pass the value from your testng.xml Useful when your dealing with simple parameter Using @DataProvider tag Useful if your reading values from prop file or database. So your testng.xml will look something of this sort: <?xml version="1.0" ...


1

Like Josa Pita says, that is nothing for testing frameworks itself. The developers could write a script to save the current version of the DB. The process should look like that: Save current version of DB/any kind of data storage. Start test run. After test run finished restore the saved version of the DB/any kind of data storage. But I think it is ...


1

When you run your TCs through TestNG, a test-output folder is created, which contains a file with name emailable-report.html, so basically you need to send that file as an attachment to the stakeholders. Here I've considered the fact that your localhost is configured to send emails. Please find below the code that you can use. import java.util.*; import ...


1

TestNG provide a lot of annotations for thinks like that: @BeforeTest, @BeforeSuite, BeforeGroups and more: http://testng.org/doc/documentation-main.html#annotations It may be look like that: @BeforeTest public void setup() { // open your popup and click on the link } @Test public void test() { // test case } @AfterTest public void tearDown() { ...


1

Your have four threads, each running test in a separate browser instance, but reading whole file again and again. This is because each thread knows nothing about what test data other threads used. A solution to the problem is to move loading and distributing test data among threads outside the test so that something else passes test data D1 to thread T1, D2 ...


1

You seem to have picked up basics correctly. I can add my inputs Selenium is mainly for web test automation. Predominantly you will simulate user actions on the website. The code generated by IDE need to be modified to make it data driven / organizing test scenarios etc If you are going to write automation code (you need to manage input data handling, ...


1

You can use the MailTrack for Gmail to check the mail has been sent or not. https://chrome.google.com/webstore/detail/mailtrack-for-gmail/ndnaehgpjlnokgebbaldlmgkapkpjkkb/related?hl=en And also http://www.hongkiat.com/blog/track-opened-gmail/.


1

Make sure you add a unique identifier to the subject. Open the send mail screen (by clicking the button in the left menu) and check the item is in there. If looking in the "send mail" screen is not enough, because you want to verify the mail is received by the other end. Then have a look at a service like Mailtrap. You can send emails to their account, ...


1

It grow too long for a comment, so here it goes: Class is like a recipe, objects is like food prepared according to it (instance of a class). You cannot test class, like you cannot taste recipe: only instance of that class is something you can interact with. Of course all instances of a class should behave the same, so you can think about "testing a ...


1

Please note that this is a generic answer; your environment may have its own interpretation that differs. In short a class is the code that describes what the object does. The object comes into existence when the class code is called and one particular object is instantiated. When it is instantiated the object sits in your computer memory ready to do its ...


1

There are at least 2 approaches: If Jenkins is used in your company, you create a job that runs tests and then e-mails report by Email ext plugin. Or you can add such functionality to @BeforeSuite method with JavaMail.


1

You would do this the same way you do any other conditional in Java: if (!SSN.isEmpty()) { //Assuming SSN is a string variable driver.findElement(By.xpath("ADD")).click(); actions.sendkeys(SSN).perform(); } This is a basic programming question; as such, I would suggest picking up a book or an online course about Java programming, as it will help ...


1

The short answer is that yes, you can do this. I don't have the code that will do it to hand, but you will find the basic information at http://msdn.microsoft.com/en-us/library/hh694602.aspx The Microsoft preferred method is to store the test data in some form of external data source (so that if the data needs to change you don't need to recompile) - the ...



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