Tag Info

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

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


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

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


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

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

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


1

I found this really simple code to write output to file. You can find it here - http://www.mkyong.com/java/how-to-write-to-file-in-java-bufferedwriter-example/ You can customize the code to fit your need and write the list values to file by placing the bw.write() part withing a loop.


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

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


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

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

Selenium standalone jar and testNg jars are missing . So just keep these jars in you Lib folder and this will resolve your problem. Since in build.xml you have provided jar location to lib folder. So please keep all your jar files in lib folder and this will start working without showing any error. Good Luck


1

Solved Error. I was missing main class of java so it was giving me error. Just added main class and then program runs successfully.


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


1

You can use reportNG. Its the reporting plugin for testNG. You can add your message using Reporter.log("Your Message"); If you want to add your alert messages in report and your project is Maven project then add following in pom.xml <reporting> <plugins> <plugin> <groupId>org.testng.xslt</groupId> ...


1

Suggestion: Every test automation shall run in a dedicated environment, dev code/script/db changes shall always auto deploy to this environment, automated test shall only run here. With such design the team can easily design the automated test an test data as well. After each success test execution, restore the whole db.


1

I did this by following code. import java.util.Properties; import javax.activation.*; import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; public class emailReport { public static void main(String[] args) { final ...


1

Instead of simple System.out.println (last line in your example) try out the following: PrintStream out = new PrintStream(System.out, true, "UTF-8"); out.println("Currency Selected:" +select.getText());



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