RC: change focus to new tab

788 views
Skip to first unread message

BillR

unread,
Dec 13, 2010, 6:28:43 PM12/13/10
to Selenium Users
When I click in a login page, a new tab is opened in FF. I don't know
how to get to it with selenium.

...
selenium_.click("//input[@value='Login']");
Thread.sleep(5000);
String[] wins = selenium_.getAllWindowNames();
for (String s : wins)
System.out.println("win: " + s);

Output: just the one window:

win: selenium_main_app_window

I notice that target=_blank:

<form name='loginform' target='_blank' action='xxx.php'
method=POST>

Not sure if that's a factor. Here's the server log:

11:58:58.513 INFO - Command request: click[//input[@value='Login'], ]
on session 17daf96137e343838b9599cf67272bf8
11:58:58.701 INFO - Got result: OK on session
17daf96137e343838b9599cf67272bf8
11:59:03.701 INFO - Command request: getAllWindowNames[, ] on session
17daf96137e343838b9599cf67272bf8
11:59:03.717 INFO - Got result: OK,selenium_main_app_window on session
17daf96137e343838b9599cf67272bf8
11:59:03.717 INFO - Command request: testComplete[, ] on session
17daf96137e343838b9599cf67272bf8

Here's the -log server output:

15:19:03.251 DEBUG [15]
org.openqa.selenium.server.SeleniumDriverResourceHandler
- res to sel_18715: json={command:"click",target:"//input[@value=
\'Login\']",va
lue:""}
15:19:03.251 DEBUG [15] org.openqa.jetty.http.HttpContext - Handled by
org.openq
a.selenium.server.SeleniumDriverResourceHandler in HttpContext[/
selenium-server,
/selenium-server]
15:19:03.251 DEBUG [15] org.openqa.jetty.http.HttpConnection -
RESPONSE:
HTTP/1.1 200 OK
Date: Mon, 13 Dec 2010 23:19:03 GMT
Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.6.0_22
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 1066


15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpConnection - REQUEST
from Sock
etLis...@0.0.0.0:4444:
POST /selenium-server/driver/?
&localFrameAddress=top&seleniumWindowName=&uniqueI
d=sel_18715&sessionId=66757eaa5bea4a8aadc943f99bcc0411&counterToMakeURsUniqueAnd
SoStopPageCachingInTheBrowser=1292282343341&sequenceNumber=17 HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive: 115
Connection: keep-alive
Content-Length: 13
Content-Type: text/plain; charset=UTF-8
Pragma: no-cache
Cache-Control: no-cache


15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpServer - Try
HttpContext[/selenium-server/driver,/selenium-server/driver],0
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpServer - Try
HttpContext[/selenium-server,/selenium-server],0
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.jetty.http.handler.SecurityHandler in HttpContext[/selenium-
server,/selenium-server]
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.StaticContentHandler in HttpContext[/
selenium-server,/selenium-server]
15:19:03.329 DEBUG [16] org.openqa.jetty.http.handler.ResourceHandler
- PATH=/driver/ RESOURCE=file:/C:/adbrite-dev/java/api_client/lib/
MISSING%20RESOURCE
15:19:03.329 DEBUG [16] org.openqa.jetty.http.handler.ResourceHandler
- Looking for file:/C:/adbrite-dev/java/api_client/lib/MISSING
%20RESOURCE
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.SessionExtensionJsHandler in HttpContext[/
selenium-server,/selenium-server]
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.htmlrunner.SingleTestSuiteResourceHandler
in HttpContext[/selenium-server,/selenium-server]
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler@16897b2
15:19:03.329 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.CachedContentTestHandler@1201a25
15:19:03.344 DEBUG [16] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.SeleniumDriverResourceHandler in
HttpContext[/selenium-server,/selenium-server]
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.SeleniumDriverResourceHandler - req: POST /
selenium-server/driver/?
&localFrameAddress=top&seleniumWindowName=&uniqueId=sel_18715&sessionId=66757eaa5bea4a8aadc943f99bcc0411&counterToMakeURsUniqueAndSoStopPageCachingInTheBrowser=1292282343341&sequenceNumber=17
HTTP/1.1
Host: localhost:4444
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.9.2.13) Gecko/20101203 Firefox/3.6.13
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive: 115
Connection: keep-alive
Content-Length: 13
Content-Type: text/plain; charset=UTF-8
Pragma: no-cache
Cache-Control: no-cache


15:19:03.344 DEBUG [16]
org.openqa.selenium.server.FrameGroupCommandQueueSet - ---------
retrieving CommandQueue for sel_18715
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.SeleniumDriverResourceHandler - Browser
66757eaa5bea4a8aadc943f99bcc0411/:top sel_18715 posted OK
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.FrameGroupCommandQueueSet - ---------
retrieving CommandQueue for sel_18715
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.SingleEntryAsyncQueue - putting command: OK
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.SingleEntryAsyncQueue - ..command put?:
true
15:19:03.344 DEBUG [16] org.openqa.selenium.server.CommandHolder
- sel_18715 commandHolder sel_18715 getCommand() called
15:19:03.344 DEBUG [16]
org.openqa.selenium.server.SingleEntryAsyncQueue - waiting for data
for at most 10 more s
15:19:03.344 DEBUG [12]
org.openqa.selenium.server.SingleEntryAsyncQueue - data from polling:
OK
15:19:03.344 DEBUG [12] org.openqa.selenium.server.CommandResultHolder
- sel_18715 commandResultHolder sel_18715 getResult() -> OK
15:19:03.344 DEBUG [12]
org.openqa.selenium.server.commands.SeleniumCoreCommand - Got result:
OK on session 66757eaa5bea4a8aadc943f99bcc0411
15:19:03.344 INFO [12]
org.openqa.selenium.server.SeleniumDriverResourceHandler - Got result:
OK on session 66757eaa5bea4a8aadc943f99bcc0411
15:19:03.344 DEBUG [12] org.openqa.jetty.http.HttpContext - Handled by
org.openqa.selenium.server.SeleniumDriverResourceHandler in
HttpContext[/selenium-server,/selenium-server]
15:19:03.344 DEBUG [12] org.openqa.jetty.http.HttpConnection -
RESPONSE:
HTTP/1.1 200 OK
Date: Mon, 13 Dec 2010 23:19:03 GMT
Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.6.0_22
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 2


15:19:08.345 DEBUG [12] org.openqa.jetty.http.HttpConnection -
EOFException()
15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpConnection - new
HttpConnection: Socket[addr=/127.0.0.1,port=3145,localport=4444]
15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpConnection - REQUEST
from SocketL...@0.0.0.0:4444:
POST /selenium-server/driver/ HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=utf-8
User-Agent: Java/1.6.0_22
Host: localhost:4444
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 64


15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpServer - Try
HttpContext[/selenium-server/driver,/selenium-server/driver],0
15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpServer - Try
HttpContext[/selenium-server,/selenium-server],0
15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.jetty.http.handler.SecurityHandler in HttpContext[/selenium-
server,/selenium-server]
15:19:08.345 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.StaticContentHandler in HttpContext[/
selenium-server,/selenium-server]
15:19:08.360 DEBUG [19] org.openqa.jetty.http.handler.ResourceHandler
- PATH=/driver/ RESOURCE=file:/C:/adbrite-dev/java/api_client/lib/
MISSING%20RESOURCE
15:19:08.360 DEBUG [19] org.openqa.jetty.http.handler.ResourceHandler
- Looking for file:/C:/adbrite-dev/java/api_client/lib/MISSING
%20RESOURCE
15:19:08.360 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.SessionExtensionJsHandler in HttpContext[/
selenium-server,/selenium-server]
15:19:08.360 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.htmlrunner.SingleTestSuiteResourceHandler
in HttpContext[/selenium-server,/selenium-server]
15:19:08.360 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler@16897b2
15:19:08.360 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.CachedContentTestHandler@1201a25
15:19:08.360 DEBUG [19] org.openqa.jetty.http.HttpContext - Handler
org.openqa.selenium.server.SeleniumDriverResourceHandler in
HttpContext[/selenium-server,/selenium-server]
15:19:08.360 DEBUG [19]
org.openqa.selenium.server.SeleniumDriverResourceHandler - req: POST /
selenium-server/driver/ HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=utf-8
User-Agent: Java/1.6.0_22
Host: localhost:4444
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 64


15:19:08.360 INFO [19]
org.openqa.selenium.server.SeleniumDriverResourceHandler - Command
request: getAllWindowNames[, ] on session
66757eaa5bea4a8aadc943f99bcc0411
...

deter

unread,
Dec 13, 2010, 11:32:19 PM12/13/10
to seleniu...@googlegroups.com
Can you post a public link which behave like this?
So that i can try on that...


santhosh soma

unread,
Dec 14, 2010, 12:38:01 AM12/14/10
to seleniu...@googlegroups.com
Hi All,

As Per my knowledge,we cant focus to new tab in firefox through selenium because selenium commands will execute only with in the tab where selenium base url opened.

Thanks
Santhosh.

On Tue, Dec 14, 2010 at 10:02 AM, deter <aler...@gmail.com> wrote:
Can you post a public link which behave like this?
So that i can try on that...



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

MAYANK SINGHAL

unread,
Dec 14, 2010, 12:53:41 AM12/14/10
to seleniu...@googlegroups.com
The website is functioning on single page
 
should we use selenium rc,how we can solve this problem?

Brian Kitchener

unread,
Dec 14, 2010, 11:52:56 AM12/14/10
to Selenium Users
What I do is create a separate firefox profile that always launches a
new window instead of a new tab.

You can find instructions here:
http://girliemangalo.wordpress.com/2009/02/05/creating-firefox-profile-for-your-selenium-rc-tests/

On Dec 13, 10:53 pm, MAYANK SINGHAL <mayank.singhal...@gmail.com>
wrote:
> The website is functioning on single page
>
> should we use selenium rc,how we can solve this problem?
>
> On Tue, Dec 14, 2010 at 11:08 AM, santhosh soma
> <santhoshvams...@gmail.com>wrote:
>
> > Hi All,
>
> > As Per my knowledge,we cant focus to new tab in firefox through selenium
> > because selenium commands will execute only with in the tab where selenium
> > base url opened.
>
> > Thanks
> > Santhosh.
>
> > On Tue, Dec 14, 2010 at 10:02 AM, deter <aleram...@gmail.com> wrote:
>
> >> Can you post a public link which behave like this?
> >> So that i can try on that...
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Selenium Users" group.
> >> To post to this group, send email to seleniu...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/selenium-users?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Selenium Users" group.
> > To post to this group, send email to seleniu...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>
> > .

BillR

unread,
Dec 14, 2010, 3:58:30 PM12/14/10
to Selenium Users
Thanks for the profile suggestion. I followed it, starting like this:

$ java -jar selenium-server.jar -firefoxProfileTemplate selenium_ff

also

$ java -jar selenium-server.jar -firefoxProfileTemplate C:/dev/java/
api_client/lib/selenium_ff

but still there is just the one window.

win: selenium_main_app_window

The log still doesn't say anything about starting a new window:

12:31:17.556 INFO - Command request: click[//input[@value='Login'], ]
on session b18b040392934c74a5df889180b41046
12:31:17.744 INFO - Got result: OK on session
b18b040392934c74a5df889180b41046
12:31:22.744 INFO - Command request: getAllWindowNames[, ] on session
b18b040392934c74a5df889180b41046

In the debug log, as before, there is an odd msg:

12:34:11.269 DEBUG [13] org.openqa.jetty.http.handler.ResourceHandler
- PATH=/driver/ RESOURCE=file:/C:/adbrite-dev/java/api_client/lib/
MISSING%20RESOURCE

This is with the new profile set as the default, e.g. when I start FF
manually from Start/Run, I see the profile selected and under Tools/
Options/Tabs that 'open new windows in a new tab instead' is
unchecked.

Does it matter if the new window is opened on a different url than the
login window (different host)?


On Dec 14, 8:52 am, Brian Kitchener <kitchener.br...@gmail.com> wrote:
> What I do is create a separate firefox profile that always launches a
> new window instead of a new tab.
>
> You can find instructions here:http://girliemangalo.wordpress.com/2009/02/05/creating-firefox-profil...
>
> On Dec 13, 10:53 pm, MAYANK SINGHAL <mayank.singhal...@gmail.com>
> wrote:
>
>
>
> > The website is functioning on single page
>
> > should we use selenium rc,how we can solve this problem?
>
> > On Tue, Dec 14, 2010 at 11:08 AM, santhosh soma
> > <santhoshvams...@gmail.com>wrote:
>
> > > Hi All,
>
> > > As Per my knowledge,we cant focus to new tab in firefox through selenium
> > > because selenium commands will execute only with in the tab where selenium
> > > base url opened.
>
> > > Thanks
> > > Santhosh.
>
> > > On Tue, Dec 14, 2010 at 10:02 AM, deter <aleram...@gmail.com> wrote:
>
> > >> Can you post a public link which behave like this?
> > >> So that i can try on that...
>
> > >> --
> > >> You received this message because you are subscribed to the Google Groups
> > >> "Selenium Users" group.
> > >> To post to this group, send email to seleniu...@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go­oglegroups.com>
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/selenium-users?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Selenium Users" group.
> > > To post to this group, send email to seleniu...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > selenium-user...@googlegroups.com<selenium-users%2Bunsubscribe@go­oglegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/selenium-users?hl=en.- Hide quoted text -
>
> - Show quoted text -

BillR

unread,
Dec 14, 2010, 4:25:15 PM12/14/10
to Selenium Users
Here's the log for launching - should it mention it's using a custom
profile?

13:22:52.495 INFO - Command request: getNewBrowserSession[*firefox,
https://madmin.xxxx.com, ] on session null
13:22:52.511 INFO - creating new remote session
13:22:52.604 INFO - Allocated session 3a03a6d4c0414561a96c08d3f8f53fb7
for https://madmin.xxxx.com, launching...
13:22:54.339 INFO - Preparing Firefox profile...
13:22:57.151 INFO - Launching Firefox...
13:22:59.761 INFO - Got result: OK,3a03a6d4c0414561a96c08d3f8f53fb7 on
session 3a03a6d4c0414561a96c08d3f8f53fb7
> > > >http://groups.google.com/group/selenium-users?hl=en.-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

BillR

unread,
Dec 14, 2010, 4:37:08 PM12/14/10
to Selenium Users
Also verified that a manually-launched browser starts a new browser on
login.


On Dec 14, 1:25 pm, BillR <r...@cgl.ucsf.edu> wrote:
> Here's the log for launching - should it mention it's using a custom
> profile?
>
> 13:22:52.495 INFO - Command request: getNewBrowserSession[*firefox,https://madmin.xxxx.com, ] on session null
> 13:22:52.511 INFO - creating new remote session
> 13:22:52.604 INFO - Allocated session 3a03a6d4c0414561a96c08d3f8f53fb7
> forhttps://madmin.xxxx.com, launching...
> > > > >http://groups.google.com/group/selenium-users?hl=en.-Hidequoted text -

BillR

unread,
Dec 15, 2010, 7:26:24 PM12/15/10
to Selenium Users
I'm able to see both windows with Selenium 2:

WebDriver driver = new FirefoxDriver();
selenium_ = new WebDriverBackedSelenium(driver, site);
...login...
for (String handle : driver.getWindowHandles())
System.out.println("win " + handle);

win {662ad6bf-c0e5-4f58-89fa-2d37ebc4898c}
win {6f3751a8-10b4-4847-ad55-eae959f65280}
> > > > > >http://groups.google.com/group/selenium-users?hl=en.-Hidequotedtext -
Reply all
Reply to author
Forward
0 new messages