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


Groups > comp.lang.python > #89989 > unrolled thread

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

Started byshweta kaushik <coolshwetu@gmail.com>
First post2015-05-05 23:55 +0530
Last post2015-05-05 23:55 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

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

Fromshweta kaushik <coolshwetu@gmail.com>
Date2015-05-05 23:55 +0530
SubjectOpen a Url in new tab and tab switching in IE using python and selenium
Message-ID<mailman.135.1430850338.12865.python-list@python.org>

[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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web