Hot answers tagged

11

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, I'...


4

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


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


4

Three tips: 1. For logging this much detail, you can implement the WebDriverEventListener (as dzieciou already said in his comment). A great explanation is found on toolsqa. This will clear up your actual code to a great extent. 2. If you want other (further) things in your log, consider using helper methods for common actions. This will again greatly ...


4

At this situation We have lots of options- Option 1 : Look for any other attribute which Is not changing every time In that div node like name, class etc. So If this div node has class attribute then we can write xpath as bellow. //div[@class='post-body entry-content']/div[1]/form[1]/input[1] Option 2 : We can use absolute xpath(full xpath) where you ...


4

JUnit 4 and TestNG are both very popular unit test framework in Java. However, TestNG's goal is much wider, which includes not only unit testing, but also support of integration and acceptance testing, etc. Which one is better or more suitable depends on use contexts and requirements. Annotations: In JUnit, the @BeforeClass and @AfterClass methods have to ...


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

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


3

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


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

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


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


3

There are two issues with your code. The first: It seems like you never apply the PageFactory on this class. Therefore, when trying the line profile.click() the variable is null (because never initialized). Hence your exception. Solution: add the following line like you did for the other classes. analyticsLandingPage landing = PageFactory.initElements(...


3

Its because you are catching the exception, your assertion is surrounded with try catch block, so your testcase gets pass. Update your catch block as below. catch(AssertionError e){ e.printStackTrace(); throw e; } OR catch(AssertionError e){ e.printStackTrace(); Assert.fail(); } This will throw the exception and your testcase will be ...


3

This shows how. "TestNG is used to enable parallel execution on runner level"


3

Major difference in TestNG and JUnit test frameworks is their scope. Junit is a unit testing framework while TestNG addresses testing at a higher level. and my recommendation is TestNG(Next Generation) Framework. Find the some references to get details about both of them- http://www.slideshare.net/ssuser220b38/junit-and-testng http://software-testing-...


2

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


2

And I have one another class which I need to run before that @BeforeClass method in four of the tests. To achieve this you can try to do this: Just make all of the four class extend this "AnotherClass" and add @BeforeClass annotation in the constructor of this class. Hope this will help.


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


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 id="...


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) { takeScreenshot(dateTimeStamp,driver,...


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" encoding="UTF-...


2

You can try using @BeforeSuite You have to group your test classes into a suite in the testng.xml and annotate the setup method in one of your test classes. This link provides a nice tutorial: http://examples.javacodegeeks.com/enterprise-java/testng/testng-beforesuite-example/


2

I have never used it but I would be surprised to find out that the popular test framework TestNG is actually the source of your intermittent results. That being said, if you want to use a different one I would recommend JUnit. The interface is similar to TestNG (Annotation based) and I've never had a problem with it.


2

Since the padding is the space inside div. When the rendered look like According to the sample HTML, I'd write my test to verify There are three objects; div1, div2 and h2. In your code, you define div2 object name to h2 actual object. It's confuse. div2 is fit inside div1, the top left right is 0px. h2 is inside div2, the left is 15px. The right is ...


2

You do not need Eclipse, Jenkins, or TestNG to scrape a website. Ask a software developer to help you package Selenium, your Java code, and any other necessary resources into an executable Jar file. If you can't find any developers, try Googling for "executable Jar file". Your executable Jar file will require a main class. If you are accustomed to ...



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