can I set title at windows?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

can I set title at windows?

include85
I have 4 windows with same name, open from testng in parallel mode.
Can I set a different name at windows for take them in different time?
Reply | Threaded
Open this post in threaded view
|

Re: can I set title at windows?

softwaretestingforum
Administrator
Not quite sure what you are trying to achieve, Could you describe more?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: can I set title at windows?

include85
Ok, sorry for my wrong english:(

I want take a window before of the event screenshot and put in first plane.

I have found this:
selenium.windowFocus(), but it doesn't want name of the window!!Strange, in documentation there is this:

windowFocus ( windowName )
    Gives focus to a window
  Arguments:
     windowName - name of the window to be given focus
Reply | Threaded
Open this post in threaded view
|

Re: can I set title at windows?

softwaretestingforum
Administrator
Do you encounter any error when you pass window name argument to focus method?
b/w I am not yet sure why you want to set these names.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: can I set title at windows?

include85
windowFocus doesn't want a windowID.

My code:
private static synchronized void captureScreenshot(ITestResult result) throws InterruptedException
	{
....
....
String screenshot_title = "ScreenshotThis";
		String orig_title_window = session().getTitle();
		session().runScript("document.title='"+screenshot_title+"'");
		//String title_window = session().getTitle();
		Thread.sleep(500);
		session().selectWindow(screenshot_title);
		Thread.sleep(500);
		session().windowFocus();
		Thread.sleep(500);
		session().windowMaximize();
		Thread.sleep(500);
		session().captureScreenshot(filePath);
		Thread.sleep(500);
		session().runScript("document.title='"+orig_title_window+"'");
		Reporter.setCurrentTestResult(null);
}

With this 'synchronized' I open in parallel four pages selenium test, when happens the error, I want selectWindow with error, windowFocus with error, windowMaximize with error and captureScreenshot.
Close it and take a new screenshot from another window with error.
Reply | Threaded
Open this post in threaded view
|

Re: can I set title at windows?

softwaretestingforum
Administrator
I noticed in Selenium API that windowFocus does not need any argument -

http://selenium.googlecode.com/svn/trunk/docs/api/java/com/thoughtworks/selenium/DefaultSelenium.html#windowFocus()

Now what are you doing will set same title for all windows, that is - screenshot_title. You may like to append time stamp to it to make it unique -

String screenshot_title = "ScreenshotThis: " _new GregorianCalendar().getTime();


~ seleniumtests.com