Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #89989

Open a Url in new tab and tab switching in IE using python and selenium

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <coolshwetu@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Open': 0.05; 'skip:p 60': 0.07; 'subject:using': 0.09; 'itself.': 0.14; 'selenium': 0.16; 'tab': 0.16; 'tab,': 0.16; 'subject:python': 0.16; 'all,': 0.19; 'trying': 0.19; 'working.': 0.19; 'solution.': 0.20; 'driver': 0.24; 'skip:" 40': 0.26; 'second': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'getting': 0.31; 'another': 0.32; 'open': 0.33; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:o 30': 0.61; 'new': 0.61; 'first': 0.61; 'provide': 0.64; 'below:': 0.68
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=welRZvmgn9PbJiG8FAcUg0YHWvfN7PicTf9J/v98lb4=; b=m7jFtAPXPcMYOqTLFn7pT2OoXY2ZEctCw23N+e7wVg3X7GS4lj9hnd5c/uMEYmtyuH GFPXQwtAi3NTpGv3aV47vB6frtDxghzN7mZh4OtrE7RSF8idkPWk6l/oLFHKSFAtsQrV SZA3uFzCCmLptpR2ypw5iStRp7wm2ODabClY5w7FXXwKXzk0jRjNsO1gyxN0w0wPjERM /SeAvNTzI12rxUY5P+vn4Z1SApi1uIR1fXh5RJDO4dXK1ua3Csiax+nH+Og2w5Eky6yL wWRu7xZyz9g7MD0BQdQchTRBruUDGnd1v4qC10hevhmn1H3ZkPWPwYujObBZyG8csqBm TSbg==
MIME-Version 1.0
X-Received by 10.202.90.197 with SMTP id o188mr4645396oib.62.1430850329696; Tue, 05 May 2015 11:25:29 -0700 (PDT)
In-Reply-To <CAM--9s5FDhvCyxZi7p3izsWncuYyjAynuYJBR30LUR4HeU2ogA@mail.gmail.com>
References <CAM--9s5FDhvCyxZi7p3izsWncuYyjAynuYJBR30LUR4HeU2ogA@mail.gmail.com>
Date Tue, 5 May 2015 23:55:29 +0530
Subject Open a Url in new tab and tab switching in IE using python and selenium
From shweta kaushik <coolshwetu@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a113d36bea0e0b7051559cda8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.135.1430850338.12865.python-list@python.org> (permalink)
Lines 93
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430850338 news.xs4all.nl 2859 [2001:888:2000:d::a6]:57311
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:89989

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi All,

I am trying to open a new tab in IE10 and selenium 2.45. It is able to open
a new tab using pyrobot. But when i am trying to open url in new tab, it is
getting opened in first tab. Focus is not set to second tab and hence it is
not working and also switching of tab is not working. please provide
solution. I have provided my code below:
Code:

# Open first tab
IEDriverPath = "/../../../../../../../IEDriverServer.exe"
driver = webdriver.Ie(IEDriverPath, port=5555)
pyseldriver.get("https://www.google.com/")
time.sleep(5)
tab1 = pyseldriver.current_window_handle

#open another tab
obja = pyrobot.Robot()
obja.key_press(pyrobot.Keys.ctrl)
obja.key_press(pyrobot.Keys.t)
obja.key_release(pyrobot.Keys.ctrl)
obja.key_release(pyrobot.Keys.t)
time.sleep(2)
pyseldriver.switch_to_window(pyseldriver.window_handles[-1])
tab2 = pyseldriver.current_window_handle
pyseldriver.get("https://www.python.org/")
time.sleep(5)

#Switching to first tab and opening new url
pyseldriver.switch_to_window(tab1)
pyseldriver.get("https://www.yahoo.com/")
time.sleep(10)

#switching to second tab and opening new url
pyseldriver.switch_to_window(tab2)
pyseldriver.get("https://www.gmail.com/")
time.sleep(10)

But links are not opening in new tab and switching is also not happening.
All links are getting opened in first tab itself.

Regards,
Shweta

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Open a Url in new tab and tab switching in IE using python and selenium shweta kaushik <coolshwetu@gmail.com> - 2015-05-05 23:55 +0530

csiph-web