Python selenium.webdriver.common.keys.Keys.CONTROL Examples

The following are 30 code examples of selenium.webdriver.common.keys.Keys.CONTROL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module selenium.webdriver.common.keys.Keys , or try the search function .
Example #1
Source File: foctor_core.py    From centinel with MIT License 7 votes vote down vote up
def switch_tab(driver):
    main_window = driver.current_window_handle
    body = driver.find_element_by_tag_name("body")
    # body.send_keys(Keys.CONTROL + 't')
    body.send_keys(Keys.CONTROL + 't')
    driver.switch_to_window(main_window)
    body_tab = driver.find_element_by_tag_name("body")
    time.sleep(.5)
    if body == body_tab:
        logging.warning("Switch tab failed")
    else:
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        body.send_keys(Keys.CONTROL + 'w')
        driver.switch_to_window(main_window)
        body_tab = driver.find_element_by_tag_name("body")
        body_tab.send_keys(Keys.CONTROL + Keys.TAB)
        driver.switch_to_window(main_window)
        body = driver.find_element_by_tag_name("body")
        if body != body_tab:
            logging.warning("Failed to switch tab, switch back to previous tab") 
Example #2
Source File: end2end_test.py    From promnesia with MIT License 6 votes vote down vote up
def test_fuzz(tmp_path, browser):
    # TODO ugh. this still results in 'tab permissions' pages, but perhaps because of closed tabs?
    # dunno if it's worth fixing..
    urls = {
        'https://www.iana.org/domains/reserved': 'IANA',
        'iana.org/domains/reserved': 'IANA2',
    }
    with _test_helper(tmp_path, index_urls(urls), 'https://example.com', browser=browser) as helper:
        driver = helper.driver
        tabs = 30
        for _ in range(tabs):
            driver.find_element_by_tag_name('a').send_keys(Keys.CONTROL + Keys.RETURN)

        sleep(5)
        for _ in range(tabs - 2):
            driver.close()
            sleep(0.1)
            driver.switch_to.window(driver.window_handles[0])

        def cb():
            for _ in range(10):
                send_key('Ctrl+Shift+t')
                sleep(0.1)
        trigger_callback(driver, cb)
        confirm("shouldn't result in 'unexpected error occured'; show only show single notification per page") 
Example #3
Source File: test_2521_CodeEditor.py    From dirigible-spreadsheet with MIT License 6 votes vote down vote up
def test_code_editor_go_to_line_function(self):
        # * Harold logs in and creates a new sheet
        self.login_and_create_new_sheet()

        # He enters some long and complicated usercode and doesn't hit "save".
        code = ""
        for i in range(200):
            code += "a\n"

        self.enter_usercode(code, commit_change=False)

        # He hits ^L, and types 100 into the resulting dialog.
        self.get_element('id=id_usercode').click()
        with self.key_down(Keys.CONTROL):
            self.human_key_press('l')
        alert = self.browser.switch_to_alert()
        alert.send_keys(100)
        alert.accept()

        # The editor jumps to line 100
        self.assertEquals(self.get_editor_selected_range(), (0, 99, 0, 99))

        # The line is, of course, visible.
        self.assert_editor_line_visible(100) 
Example #4
Source File: test_utils.py    From sos-notebook with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def edit_prompt_cell(self,
                         content,
                         kernel='SoS',
                         execute=False,
                         expect_error=False):
        # print("panel", self.prompt_cell.get_attribute("innerHTML"))
        self.browser.execute_script("window.my_panel.cell.set_text(" +
                                    repr(dedent(content)) + ")")

        # the div is not clickable so I use send_key to get around it
        self.prompt_cell.send_keys('\n')
        self.select_console_kernel(kernel)
        #   self.prompt_cell.find_element_by_css_selector('.CodeMirror').click()
        if execute:
            self.prompt_cell.send_keys(Keys.CONTROL, Keys.ENTER)
            self._wait_for_done(-1, expect_error=expect_error) 
Example #5
Source File: test_utils.py    From sos-notebook with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def execute_cell(self,
                     cell_or_index=None,
                     in_console=False,
                     expect_error=False):
        if isinstance(cell_or_index, int):
            index = cell_or_index
        elif isinstance(cell_or_index, WebElement):
            index = self.index(cell_or_index)
        else:
            raise TypeError("execute_cell only accepts a WebElement or an int")
        self._focus_cell(index)
        if in_console:
            self.current_cell.send_keys(Keys.CONTROL, Keys.SHIFT, Keys.ENTER)
            self._wait_for_done(-1, expect_error)
        else:
            self.current_cell.send_keys(Keys.CONTROL, Keys.ENTER)
            self._wait_for_done(index, expect_error) 
Example #6
Source File: crawler.py    From coverage-crawler with Mozilla Public License 2.0 6 votes vote down vote up
def find_children(driver):
    body = driver.find_elements_by_tag_name('body')
    assert len(body) == 1
    body = body[0]

    body.send_keys(Keys.CONTROL, 0)

    buttons = body.find_elements_by_tag_name('button')
    links = body.find_elements_by_tag_name('a')
    inputs = body.find_elements_by_tag_name('input')
    selects = body.find_elements_by_tag_name('select')
    children = buttons + links + inputs + selects

    random.shuffle(children)

    return children 
Example #7
Source File: vmware.py    From RENAT with Apache License 2.0 6 votes vote down vote up
def send_mks_keys(self,keys,wait='5s'):
    """ Sends key strokes to current web console

    Special Ctrl char could be used as ``${CTRL_A}`` to ``${CTRL_Z}``

    Examples:
    | `Send MKS Key`   |     ${CTRL_L} |

    *Notes*: For other usable key value, see Selenium document
    """
    driver = BuiltIn().get_library_instance('SeleniumLibrary')
    canvas = driver.get_webelement('mainCanvas')
    if len(keys) == 1 and ord(keys) < ord('@'):
        canvas.send_keys(Keys.CONTROL + chr(ord(keys) + ord('@')))
    else:
        canvas.send_keys(keys)
    time.sleep(DateTime.convert_time(wait))
    BuiltIn().log('Sent keystrokes to the web console') 
Example #8
Source File: elements.py    From gigantum-client with MIT License 5 votes vote down vote up
def ctrl_shift_enter(self, actions):
        """Useful for executing a code block"""
        return actions.key_down(Keys.SHIFT).key_down(Keys.CONTROL).send_keys(Keys.ENTER) \
            .key_up(Keys.SHIFT).key_up(Keys.CONTROL).perform() 
Example #9
Source File: test_formgrader.py    From nbgrader with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_same_part_navigation(browser, port, gradebook):
    problem = gradebook.find_notebook("Problem 1", "Problem Set 1")
    submissions = problem.submissions
    submissions.sort(key=lambda x: x.id)

    # Load the first submission
    utils._get(browser, utils._formgrade_url(port, "submissions/{}".format(submissions[0].id)))
    utils._wait_for_formgrader(browser, port, "submissions/{}/?index=0".format(submissions[0].id))

    # Click the second comment box and navigate to the next submission
    utils._get_comment_box(browser, 1).click()
    utils._send_keys_to_body(browser, Keys.CONTROL, ".")
    utils._wait_for_formgrader(browser, port, "submissions/{}/?index=6".format(submissions[1].id))
    element_active = lambda browser: utils._get_active_element(browser) == utils._get_comment_box(browser, 1)
    WebDriverWait(browser, 10).until(element_active)

    # Click the third score box and navigate to the previous submission
    utils._get_score_box(browser, 2).click()
    utils._send_keys_to_body(browser, Keys.CONTROL, ",")
    utils._wait_for_formgrader(browser, port, "submissions/{}/?index=7".format(submissions[0].id))
    element_active = lambda browser: utils._get_active_element(browser) == utils._get_score_box(browser, 2)
    WebDriverWait(browser, 10).until(element_active)

    # Click the third comment box and navigate to the next submission
    utils._get_comment_box(browser, 2).click()
    utils._send_keys_to_body(browser, Keys.CONTROL, ".")
    utils._wait_for_formgrader(browser, port, "submissions/{}/?index=11".format(submissions[1].id))
    element_active = lambda browser: utils._get_active_element(browser) == utils._get_score_box(browser, 4)
    WebDriverWait(browser, 10).until(element_active)

    # Navigate to the previous submission
    utils._send_keys_to_body(browser, Keys.CONTROL, ",")
    utils._wait_for_formgrader(browser, port, "submissions/{}/?index=11".format(submissions[0].id))
    element_active = lambda browser: utils._get_active_element(browser) == utils._get_score_box(browser, 4)
    WebDriverWait(browser, 10).until(element_active) 
Example #10
Source File: formgrade_utils.py    From nbgrader with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _flag(browser):
    _send_keys_to_body(browser, Keys.SHIFT, Keys.CONTROL, "f")
    message = browser.find_element_by_id("statusmessage")
    WebDriverWait(browser, 10).until(lambda browser: message.is_displayed())
    WebDriverWait(browser, 10).until(lambda browser: not message.is_displayed())
    return browser.execute_script("return $('#statusmessage').text();") 
Example #11
Source File: element.py    From nerodia with MIT License 5 votes vote down vote up
def click(self, *modifiers):
        """
        Clicks the element, optionally while pressing the given modifier keys.
        Note that support for holding a modifier key is currently experimental, and may not work
        at all.

        :param modifiers: modifier keys to press while clicking
        :Example: Click an element

        browser.element(name='new_user_button').click()

        :Example: Click an element with shift key pressed
        from selenium.webdriver.common.keys import Keys
        browser.element(name='new_user_button').click(Keys.SHIFT)

        :Example: Click an element with several modifier keys pressed
        from selenium.webdriver.common.keys import Keys
        browser.element(name='new_user_button').click(Keys.SHIFT, Keys.CONTROL)
        """

        def method():
            if modifiers:
                action = ActionChains(self.driver)
                for mod in modifiers:
                    action.key_down(mod)
                action.click(self.el)
                for mod in modifiers:
                    action.key_up(mod)
                action.perform()
            else:
                self.el.click()

        self._element_call(method, self.wait_for_enabled)
        self.browser.after_hooks.run() 
Example #12
Source File: end2end_test.py    From promnesia with MIT License 5 votes vote down vote up
def test_new_background_tab(tmp_path, browser):
    start_url = "http://www.e-flux.com/journal/53/59883/the-black-stack/"
    # bg_url_text = "El Proceso (The Process)"
    # TODO generate some fake data instead?
    with _test_helper(tmp_path, index_hypothesis, start_url, browser=browser) as helper:
        confirm('you should see notification about contexts')
        helper.driver.find_element(By.XPATH, '//div[@class="logo"]/a').send_keys(Keys.CONTROL + Keys.ENTER)
        confirm('you should not see any new notifications')
        # TODO switch to new tab?
        # TODO https://www.e-flux.com/journal/53/ 
Example #13
Source File: testvideo.py    From netflix-proxy with MIT License 5 votes vote down vote up
def enablePlayerDiagnostics(self):
        actions = ActionChains(self.driver)
        actions.key_down(Keys.CONTROL).key_down(Keys.ALT).key_down(Keys.SHIFT).send_keys('d').perform() 
Example #14
Source File: test_frontend.py    From sos-notebook with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_clear_history(self, notebook):
        notebook.edit_prompt_cell("a = 1", execute=True)
        notebook.edit_prompt_cell("b <- 2", kernel="R", execute=True)
        # use "clear" to clear all panel cells
        notebook.edit_prompt_cell("clear", kernel="SoS", execute=False)
        # we cannot wait for the completion of the cell because the cells
        # will be cleared
        notebook.prompt_cell.send_keys(Keys.CONTROL, Keys.ENTER)
        assert not notebook.panel_cells 
Example #15
Source File: smsRB.py    From RomanceBreaker with GNU General Public License v3.0 5 votes vote down vote up
def morningMessage():
    #Sending message
    global driver
    global bae
    msg = random.choice(config.custom_morning_messages)
    try:
        pyperclip.copy(bae)
        searchbar = driver.find_elements_by_xpath(
            '//*[@id="yDmH0d"]/c-wiz/div/div/div/div/div/div[1]/div[3]/div/div[2]/div[3]')[0]
        searchbar.click()
        time.sleep(1)
        newmessage = driver.find_element_by_xpath(
            '//*[@id="yDmH0d"]/c-wiz/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/div/div/div/div[1]/div/div[1]/input')
        newmessage.send_keys(Keys.CONTROL, 'v')
        msg = random.choice(config.custom_morning_messages)
        pyperclip.copy(msg)
        time.sleep(5)
        newmessage.send_keys(Keys.ENTER)
        time.sleep(6.5)
        message = driver.find_elements_by_xpath(
            '//*[@id="yDmH0d"]/c-wiz/div/div/div/div/div/div[2]/div/div[3]/div/div/div[3]/div[2]/div[1]/div/div[2]/div/div[1]')[0]
        message.send_keys(Keys.CONTROL, 'v')
        message.send_keys(Keys.ENTER)
        print("Message {} successfully sent to {}" .format(msg, bae))
    except:
        print("Problem sending, retrying...")
        morningMessage()
        pass
    return


#Getting username & pwd 
Example #16
Source File: whatsappRB.py    From RomanceBreaker with GNU General Public License v3.0 5 votes vote down vote up
def morningMessage():
    #Sending message
    global driver
    global bae
    msg = random.choice(config.custom_morning_messages)
    baestr = str('"' + bae + '"')

    #Some Selenium stuff, don't bother
    try:
        pyperclip.copy(bae)
        searchbar = driver.find_elements_by_xpath('//*[@id="side"]/div[1]/div/label/input')[0]
        searchbar.click() #Click on searchbar
        searchbar.send_keys(Keys.CONTROL, 'v') #Search for contact for more speed
        x_arg = '//span[contains(@title,' + baestr + ')]'
        group_title = wait.until(EC.presence_of_element_located((By.XPATH, x_arg)))
        group_title.click()
        time.sleep(0.1)
        pyperclip.copy(msg) #Copies random message to clipboard
        message = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')[0]
        message.send_keys(Keys.CONTROL, 'v') #Sends message from clipboard
        time.sleep(0.1)
        sendbutton = driver.find_elements_by_xpath('//*[@id="main"]/footer/div[1]/div[3]/button')[0]
        sendbutton.click() #Presses send button
        searchbar.click() #Click on searchbar
        searchbar.send_keys(Keys.CONTROL, 'a') #Select all
        searchbar.send_keys(Keys.DELETE) #Delete searchbar content
        print("Message {} successfully sent to {}" .format(msg, bae))
    except:
        print("Problem sending, retrying...")
        morningMessage()
        pass
    return

#Getting username & pwd 
Example #17
Source File: upload.py    From bilibiliupload with MIT License 5 votes vote down vote up
def add_information(driver, link, title_):
        # 点击模板
        driver.find_element_by_xpath(r'//*[@class="normal-title-wrp"]/div/p').click()
        driver.find_element_by_class_name(r'template-list-small-item').click()
        # driver.find_element_by_xpath(
        #     r'//*[@id="app"]/div[3]/div[2]/div[3]/div[1]/div[1]/div/div[2]/div[1]').click()
        # 输入转载来源
        input_o = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[4]/div[3]/div/div/input')
        input_o.send_keys(link)
        # 选择分区
        # driver.find_element_by_xpath(r'//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/div[3]/div').click()
        # driver.find_element_by_xpath(r'//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[2]/div[2]/div[1]/div[3]/div[2]/div[6]').click()
        # 稿件标题
        title = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[8]/div[2]/div/div/input')
        title.send_keys(Keys.CONTROL + 'a')
        title.send_keys(Keys.BACKSPACE)
        title.send_keys(title_)
        # js = "var q=document.getElementsByClassName('content-tag-list')[0].scrollIntoView();"
        # driver.execute_script(js)
        # time.sleep(3)
        # 输入相关游戏
        # driver.save_screenshot('bin/err.png')
        # print('截图')
        # text_1 = driver.find_element_by_xpath(
        #     '//*[@id="item"]/div/div[2]/div[3]/div[2]/div[2]/div[1]/div[5]/div/div/div[1]/div[2]/div/div/input')
        # text_1.send_keys('星际争霸2')
        # 简介
        text_2 = driver.find_element_by_xpath(
            '//*[@class="upload-v2-container"]/div[2]/div[3]/div[1]/div[12]/div[2]/div/textarea')
        text_2.send_keys('职业选手直播第一视角录像。这个自动录制上传的小程序开源在Github:'
                         'http://t.cn/RgapTpf(或者在Github搜索ForgQi)交流群:837362626'
                         '\n顺便推广一下自己的网站http://web-form.me/') 
Example #18
Source File: webdriver.py    From seldom with Apache License 2.0 5 votes vote down vote up
def paste(self):
            if platform.system().lower() == "darwin":
                self.elem.send_keys(Keys.COMMAND, "v")
            else:
                self.elem.send_keys(Keys.CONTROL, "v") 
Example #19
Source File: webdriver.py    From seldom with Apache License 2.0 5 votes vote down vote up
def copy(self):
            if platform.system().lower() == "darwin":
                self.elem.send_keys(Keys.COMMAND, "c")
            else:
                self.elem.send_keys(Keys.CONTROL, "c") 
Example #20
Source File: webdriver.py    From seldom with Apache License 2.0 5 votes vote down vote up
def cut(self):
            if platform.system().lower() == "darwin":
                self.elem.send_keys(Keys.COMMAND, "x")
            else:
                self.elem.send_keys(Keys.CONTROL, "x") 
Example #21
Source File: webdriver.py    From seldom with Apache License 2.0 5 votes vote down vote up
def select_all(self):
            if platform.system().lower() == "darwin":
                self.elem.send_keys(Keys.COMMAND, "a")
            else:
                self.elem.send_keys(Keys.CONTROL, "a") 
Example #22
Source File: test_2521_CodeEditor.py    From dirigible-spreadsheet with MIT License 5 votes vote down vote up
def test_code_editor_find_function(self):
        # * Harold logs in and creates a new sheet
        self.login_and_create_new_sheet()

        # He enters some long and complicated usercode, which contains the string "123" at a well-known place,
        # and doesn't hit "save".
        code = ""
        for i in range(100):
            code += "a\n"
        code += "abc123def"
        for i in range(100):
            code += "a\n"

        self.enter_usercode(code, commit_change=False)

        # He hits ^F, and types 123 into the resulting dialog.
        self.get_element('id=id_usercode').click()
        with self.key_down(Keys.CONTROL):
            self.human_key_press('f')
        alert = self.browser.switch_to_alert()
        alert.send_keys(123)
        alert.accept()

        # The editor jumps to the "123" bit and selects it.
        self.assertEquals(self.get_editor_selected_range(), (3, 100, 6, 100))

        # The line is, of course, visible.
        self.assert_editor_line_visible(100) 
Example #23
Source File: webelement.py    From knitter with GNU General Public License v3.0 5 votes vote down vote up
def Refresh(self, times=4):
        logger.step_normal("Element [%s]: Browser Refresh" % (self.__name__,))

        for i in range(times):
            action = webdriver.ActionChains(Browser.RunningBrowser)
            action.key_down(Keys.CONTROL).send_keys(Keys.F5).key_up(Keys.CONTROL).perform()
            time.sleep(5) 
Example #24
Source File: __init__.py    From selenium-python-helium with MIT License 5 votes vote down vote up
def press(key):
	"""
	:param key: Key or combination of keys to be pressed.

	Presses the given key or key combination. To press a normal letter key such
	as 'a' simply call `press` for it::

		press('a')

	You can also simulate the pressing of upper case characters that way::

		press('A')

	The special keys you can press are those given by Selenium's class
	:py:class:`selenium.webdriver.common.keys.Keys`. Helium makes all those keys
	available through its namespace, so you can just use them without having to
	refer to :py:class:`selenium.webdriver.common.keys.Keys`. For instance, to
	press the Enter key::

		press(ENTER)

	To press multiple keys at the same time, concatenate them with `+`. For
	example, to press Control + a, call::

		press(CONTROL + 'a')
	"""
	_get_api_impl().press_impl(key) 
Example #25
Source File: base.py    From tir with MIT License 5 votes vote down vote up
def send_keys(self, element, arg):
        """
        [Internal]

        Clicks two times on the Selenium element.

        :param element: Selenium element
        :type element: Selenium object
        :param arg: Text or Keys to be sent to the element
        :type arg: str or selenium.webdriver.common.keys

        Usage:

        >>> #Defining the element:
        >>> element = lambda: self.driver.find_element_by_id("example_id")
        >>> #Calling the method with a string
        >>> self.send_keys(element(), "Text")
        >>> #Calling the method with a Key
        >>> self.send_keys(element(), Keys.ENTER)
        """
        try:
            if arg.isprintable():
                element.clear()
                element.send_keys(Keys.CONTROL, 'a')
            element.send_keys(arg)
        except Exception:
            actions = ActionChains(self.driver)
            actions.move_to_element(element)
            actions.click()
            if arg.isprintable():
                actions.key_down(Keys.CONTROL).send_keys('a').key_up(Keys.CONTROL).send_keys(Keys.DELETE)
            actions.send_keys(Keys.HOME)
            actions.send_keys(arg)
            actions.perform() 
Example #26
Source File: page_objects.py    From poium with Apache License 2.0 5 votes vote down vote up
def paste(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "v")
        else:
            elem.send_keys(Keys.CONTROL, "v") 
Example #27
Source File: page_objects.py    From poium with Apache License 2.0 5 votes vote down vote up
def copy(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "c")
        else:
            elem.send_keys(Keys.CONTROL, "c") 
Example #28
Source File: page_objects.py    From poium with Apache License 2.0 5 votes vote down vote up
def cut(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "x")
        else:
            elem.send_keys(Keys.CONTROL, "x") 
Example #29
Source File: page_objects.py    From poium with Apache License 2.0 5 votes vote down vote up
def select_all(self):
        elem = self.__get_element(self.k, self.v)
        if platform.system().lower() == "darwin":
            elem.send_keys(Keys.COMMAND, "a")
        else:
            elem.send_keys(Keys.CONTROL, "a") 
Example #30
Source File: test_environment.py    From gigantum-client with MIT License 4 votes vote down vote up
def test_packages(driver: selenium.webdriver, *args, **kwargs):
    """
    Test that pip ,conda, and apt packages install successfully.

    Args:
        driver
    """
    r = testutils.prep_py3_minimal_base(driver)
    username, project_title = r.username, r.project_name
    pip_package_construct = ("construct", "2.9.45")
    conda_package_requests = ("requests", "2.22.0")
    apt_package_vim = "vim-tiny"

    # Install pip, conda, and apt packages
    env_elts = testutils.EnvironmentElements(driver)
    env_elts.open_add_packages_modal(username, project_title)
    env_elts.add_pip_package(pip_package_construct[0], pip_package_construct[1])
    env_elts.add_conda_package(conda_package_requests[0], conda_package_requests[1])
    env_elts.add_apt_package(apt_package_vim)
    env_elts.install_queued_packages()

    # Open JupyterLab and create Jupyter notebook
    project_control_elts = testutils.ProjectControlElements(driver)
    project_control_elts.launch_devtool("JupyterLab")
    project_control_elts.open_devtool_tab("JupyterLab")
    jupyterlab_elts = testutils.JupyterLabElements(driver)
    jupyterlab_elts.jupyter_notebook_button.wait_to_appear().click()
    time.sleep(5)
    logging.info("Running script to import packages and print package versions")
    package_script = "import construct\nimport requests\n" \
                     "print(construct.__version__,requests.__version__)"
    actions = ActionChains(driver)
    actions.move_to_element(jupyterlab_elts.code_input.wait_to_appear()) \
        .click(jupyterlab_elts.code_input.find()) \
        .send_keys(package_script) \
        .key_down(Keys.SHIFT).send_keys(Keys.ENTER).key_up(Keys.SHIFT).key_up(Keys.CONTROL) \
        .perform()
    jupyterlab_elts.code_output.wait_to_appear()

    # Get JupyterLab package versions
    logging.info("Extracting package versions from JupyterLab")
    environment_package_versions = [pip_package_construct[1], conda_package_requests[1]]
    jupyterlab_package_versions = jupyterlab_elts.code_output.find().text.split(" ")
    logging.info(f"Environment package version {environment_package_versions} \n "
                 f"JupyterLab package version {jupyterlab_package_versions}")

    assert environment_package_versions == jupyterlab_package_versions,\
        "Environment and JupyterLab package versions do not match"