1

Description of my web page:

When I enter some details on my web Page it shows up couple of different links.

Out of that links, I need to click on one link and continue my testing from there on.

The problem is the new link always opens in a new Tab instead of a new window. I have tried the following option but it still opens the new link a Tab only.

Method 1 tried:

 link =  driver.find_element_by_partial_link_text("MyLink")
 action = ActionChains(driver)
 action.key_down(Keys.CONTROL).click(link).key_up(Keys.CONTROL).perform()
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
user2744620
  • 439
  • 1
  • 9
  • 21

1 Answers1

0

You need to either:

a) set a wait time or

b) hover over the element and then click.

See: Is there a way to perform a mouseover (hover over an element) using Selenium and Python bindings?

Community
  • 1
  • 1
Bobby Russell
  • 475
  • 2
  • 12
  • I have tried the option mentioned in the link you gave me . It is not working either. Any other suggestions? When I run my scripts it is still opening the new link in a new tab. I want that link to be opened in a new window instead. – user2744620 Sep 08 '14 at 23:07
  • 1
    You should post your HTML if you want more help, it's difficult to tell what's going on without that. – Bobby Russell Sep 08 '14 at 23:33
  • Thanks Bobby. I used this following code and I was able to perform "Right click - Open Link in new Window" and Switch to New Window. link = driver.find_element_by_partial_link_text("My LinK") action = ActionChains(driver) action.key_down(Keys.SHIFT).click(link).key_up(Keys.SHIFT).perform() time.sleep(15) self.driver.switch_to_window(driver.window_handles[-1]) title = self.driver.title – user2744620 Sep 09 '14 at 03:40