--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
I don't have any code here as I'm thousands of miles away from home, sorry.
> To unsubscribe from this group, send email to testng-users...@googlegroups.com.
You can set up listener in your configuration method as follows.
@BeforeMethod
public void setUp(ITestContext context) {
TestRunner runner = (TestRunner) context;
runner.addListener(new ScreenshotListener());
}
Cédric
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
I actually saw this implementation. It seems to be supported by Selenium itself.
Figured I would ask before having to do it myself. :)
-adam
> It will stop working if I decide one day that I no longer want
> TestRunner to implement ITestContext...
>
> --
> C�dric
I have it at home, so if you can't wait one week while I'm still
enjoying the States, you are free to go ahead and implement it
yourself :)
FK
-adam
> Adam,
>
> I have it at home, so if you can't wait one week while I'm still
> enjoying the States, you are free to go ahead and implement it
> yourself :)
>
> FK
>
> On Tue, Oct 26, 2010 at 4:56 PM, Adam Goucher<ad...@goucher.ca> wrote:
>> Does anyone care to prepare the summarized version of a solution to this
>> given this warning (including registration of it outside of testng.xml)?
>> Preferably hybridizing Ajay's extension of TestListenerAdapter with Dan's
>> filtration of internal Se errors.
>>
>> Figured I would ask before having to do it myself. :)
>>
>> -adam
>>
>>> It will stop working if I decide one day that I no longer want TestRunner
>>> to implement ITestContext...
>>>
>>> --
>>> C�dric
Good question. I was just logging a hyperlink but it would be cool to
embed it directly in. Cedric, is there a way to do this?
public class WebDriverManager
{
private static WebDriver driver = null;
private static String browser = null;
// Default constructor, no need to extend this just use as a static
public WebDriverManager() {
}
/**
* Static method for starting a webdriver, defaults the wait time to 30 seconds and the browser to
* the firefox driver.
*/
public static WebDriver startDriver(String browser, String portalUrl, int timeout)
{
WebDriverManager.browser = browser;
/*
* Determine what browser were using and start the appropiate driver instance
*/
if ( browser.equalsIgnoreCase("INTERNET_EXPLORER") )
{
System.out.println("browser : "+ browser);
// start a internet explorer driver instance
driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// open the url
driver.get(portalUrl);
driver.manage().deleteAllCookies();
}
else if ( browser.equalsIgnoreCase("HTML_UNIT") )
{
System.out.println("browser : "+ browser);
// start a html unit driver instance and enable javascript
driver = new HtmlUnitDriver(true);
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// open the url
driver.get(portalUrl);
driver.manage().deleteAllCookies();
new Actions(driver).keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();
}
/**
* Installation and configuration steps for the Chrome driver.....
*
* 1. Go to http://code.google.com/p/chromium/downloads/list and download the latest chromedriver for windows
* 2. Extract the chromedriver.exe to a location of your choice
* 3. Create a webdriver.chrome.driver environment variable and set the path to the chromedriver.exe including
* the chromedriver.exe in the path.
*/
else if ( browser.equalsIgnoreCase("CHROME") )
{
System.out.println("browser :"+ browser);
/**
* Chrome web driver requires a webdriver.chrome.driver property to be set to the path of the
* chrome driver exe so create a webdriver.chrome.driver environment variable and determine
* where the driver exe resides for each machine instance via this variable.
* Use the environment variable to then set the property.
*/
try
{
String chromeDriverPath = System.getenv( "webdriver.chrome.driver" );
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
}
catch (Exception ex)
{
System.out.println("\nException in getting and setting the webdriver chrome driver: "
+ ex.getMessage() + ex.getClass() );
ex.printStackTrace();
}
/*
* Configure chrome to ignore the untrusted certificate error for secure ssl. More information can
* be found here...
*
* http://code.google.com/p/selenium/wiki/ChromeDriver
*/
ChromeOptions options = new ChromeOptions();
options.addArguments(Arrays.asList(new String[]{"--ignore-certificate-errors", "--start-maximized"}));
driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// open the url
driver.get(portalUrl);
driver.manage().deleteAllCookies();
new Actions(driver).keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();
}
else if ( browser.equalsIgnoreCase("OPERA") )
{
System.out.println("browser :"+ browser);
DesiredCapabilities operaCapabilities = DesiredCapabilities.opera();
operaCapabilities.setJavascriptEnabled(true);
operaCapabilities.setCapability("-autotestmode", true);
driver = new OperaDriver(operaCapabilities);
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// open the url
driver.get(portalUrl);
driver.manage().deleteAllCookies();
new Actions(driver).keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();
}
else
{
System.out.println("browser : Firefox (Default)\n");
// start a firefox driver instance
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS);
// open the url
driver.get(portalUrl);
driver.manage().deleteAllCookies();
new Actions(driver).keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();
}
// return a reference to the static web driver instance started
return driver;
}
/**
* Stops the browser driver started
*
* @param - the instance of the driver to stop
*/
public static void stopDriver()
{
driver.quit();
}
public static WebDriver getDriverInstance()
{
return driver;
}
/**
* Getter method for the currect browser being used for testing
* @return the browser string being used for testing
*/
public static String getBroswer()
{
return browser;
}
} //end class
can anyone help me in using the screenshot in build Ant file.. i got the
below code from Google search but when implemented i am getting some
errors... build failed.. can you give me the ant file with the listeners
below.. thanks
<testng listeners="org.fest.swing.testng.ScreenshotOnFailureListener"
outputDir="${target.test.results.dir}" haltOnFailure="true"
verbose="2">
<classfileset dir="${target.test.classes.dir}" includes="**/*Test.class"
/>
<classpath location="${target.test.classes.dir}" />
<classpath location="${target.classes.dir}" />
<classpath refid="test.classpath" />
</testng>
Sella ra wrote:
>
> Hi,
>
> I am very new to Selenium.
>
> Could you please help me with the steps to Capture Screenshot on failure
> using TestNG Framework in selenium?
>
> It would be of great help to me.
>
> Thanks lot.
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To post to this group, send email to testng...@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>
>
--
View this message in context: http://old.nabble.com/TestNG-Selenium-Capture-Screenshot-on-failure-tp29991790p33256726.html
Sent from the testng-users mailing list archive at Nabble.com.
can anyone help me in using the screenshot code in build Ant file and
testng.xml.. i got the below code from Google search but when implemented i
am getting some errors... build failed.. can you give me the ant file with
the listeners below.. thanks
<testng listeners="org.fest.swing.testng.ScreenshotOnFailureListener"
outputDir="${target.test.results.dir}" haltOnFailure="true"
verbose="2">
<classfileset dir="${target.test.classes.dir}" includes="**/*Test.class"
/>
<classpath location="${target.test.classes.dir}" />
<classpath location="${target.classes.dir}" />
<classpath refid="test.classpath" />
</testng>
--
View this message in context: http://old.nabble.com/TestNG-Selenium-Capture-Screenshot-on-failure-tp29991790p33256729.html
can anyone help me in using the screenshot in build Ant file and
TestNg.xml.. i got the below code from Google search but when implemented i
am getting some errors... build failed.. can you give me the ant file with
the listeners below.. thanks
<testng listeners="org.fest.swing.testng.ScreenshotOnFailureListener"
outputDir="${target.test.results.dir}" haltOnFailure="true"
verbose="2">
<classfileset dir="${target.test.classes.dir}" includes="**/*Test.class"
/>
<classpath location="${target.test.classes.dir}" />
<classpath location="${target.classes.dir}" />
<classpath refid="test.classpath" />
</testng>
--
View this message in context: http://old.nabble.com/TestNG-Selenium-Capture-Screenshot-on-failure-tp29991790p33256730.html