There is a link on my tested page which is opened in new TAB by default. I need to open the link and verify some values on the newly opened page. As I found selenium does not support working with tabs, so I am trying to open the link in new window, but it still does not work.. I implemented python function to hold SHIFT key (I have done this before for CTRL and it works) and then I called "click" function, but the link is still being opened in new tab
from robot.libraries.BuiltIn import BuiltIn
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
class CustomSeleniumLibrary(object):
def __init__(self):
self.driver = None
self.library = None
self.ac = None
def get_library_instance(self):
if self.library is None:
self.library = BuiltIn().get_library_instance('ExtendedSelenium2Library')
return self.library
def get_action_chain(self):
if self.ac is None:
self.ac = ActionChains(self.get_library_instance()._current_browser())
return self.ac
def hold_shift(self):
actionChain = self.get_action_chain()
actionChain.key_down(Keys.SHIFT)
actionChain.perform()
The robot keyword is
Open project detail
wait until element is visible ${LINK_TO_PROJECT}
${project}= get text ${LINK_TO_PROJECT}
hold shift
click element ${LINK_TO_PROJECT}
#sleep 2s
#release shift
element should contain //h3 Project Details: ${project}
I tried many variants with sleeps, releasing the key etc. but it never really opens the link in new window. I also tried to verify the data in newly opened tab (without trying to open in new window), but it is always redirected into original tab very quickly so the DOM on new tab is not loaded yet.. Thanks for any suggestion!