Pylenium.io
GitHub ↗️
  • Welcome to Pylenium
  • Getting Started
    • 1. Virtual Environments
    • 2. Setup pytest
    • 3. Project Structure with pytest
    • 4. Writing Tests with Pylenium
  • Guides
    • πŸ“ŠVisualize Test Results with Allure
    • πŸ“Logging
    • 🟨Run Tests in Containers
    • πŸ”€Run Tests in Parallel
    • πŸ§ͺShould / Expected Conditions
    • 🌐Script with Standalone Pylenium
  • CLI
    • πŸ’»Pylenium CLI
    • πŸ“ŠAllure CLI
  • Configuration
    • πŸ“„pylenium.json
    • πŸš—Driver
    • πŸ–₯️Viewport
  • Fixtures
    • ↗️api
    • πŸͺ“axe
    • πŸ₯Έfake
    • βœ…py
    • β˜‘οΈpyc
    • ❌pys
  • Driver Commands
    • Overview
    • πŸ—ΊοΈNavigation
      • go
      • quit
      • reload
      • visit
    • πŸ”Find Elements
      • contains
      • find
      • findx
      • get
      • getx
    • ⏱️Driver.should()
    • 🌐Browser
      • execute_script
      • execute_async_script
      • maximize_window
      • screenshot
      • scroll_to
      • title
      • url
      • window_handles
      • window_size
      • viewport
    • πŸͺCookies
      • delete_all_cookies
      • delete_cookie
      • get_all_cookies
      • get_cookie
      • set_cookie
    • πŸ”„Switch To
      • default_content
      • frame
      • frame_by_element
      • parent_frame
      • window
      • new_window
      • new_tab
    • πŸ“ŠWeb Performance
      • Performance API
      • CDP Performance
    • fake
    • wait
    • webdriver
  • Element Commands
    • πŸ”Find Elements
    • ⏱️Element.should()
    • πŸ‘Actions
      • check
      • clear
      • click
      • deselect
      • double_click
      • drag_to
      • drag_to_element
      • focus
      • hover
      • right_click
      • scroll_into_view
      • select_by_index
      • select_by_text
      • select_by_value
      • submit
      • type
      • uncheck
      • upload
    • πŸ”’Element Data
      • css_value
      • get_attribute
      • get_property
      • tag_name
      • text
      • is_checked
      • is_displayed
      • is_enabled
      • is_selected
    • πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦Family
      • children
      • parent
      • siblings
    • open_shadow_dom
    • screenshot
    • webelement
  • Elements Commands
    • ⏱️Elements.should()
    • first
    • length
    • last
    • is_empty
  • Contribute
    • Clone and Setup the Project
Powered by GitBook
On this page
  • Syntax
  • Usage
  • Arguments
  • Yields
  • Examples
  1. Element Commands
  2. Actions

type

The command to type keys into a field, input or text box.

Replaces send_keys from Selenium

Syntax

Element.type(*args) -> Element

Usage

correct usage
py.get("#username").type("my-username")

---or--- # combine with other keys and strings

# import the Keys from selenium
py.get("#search").type("puppies", Keys.ENTER)

---or--- # chain an Element command

py.get("#email").type("foo@example.com").get_attribute("value")
incorrect usage
# Errors, 'type' may have no effect on other types of elements
py.get("a").type("foo")

Arguments

  • *args (Any) - A comma-separated list of arguments to type

It's best to use strings and the Keys from Selenium

Yields

  • Element - The current Element so you can chain commands

Examples

Given this HTML:

<form name="login" id="login" action="/authenticate" method="post">
    <div class="row">
      <div class="large-6 small-12 columns">
        <label for="username">Username</label>
        <input type="text" name="username" id="username">
      </div>
    </div>
    <div class="row">
      <div class="large-6 small-12 columns">
        <label for="password">Password</label>
        <input type="password" name="password" id="password">
      </div>
    </div>
      <button class="radius" type="submit"><i class="fa fa-2x fa-sign-in"> Login</i></button>
</form>

We could type credentials into the fields and submit the form to login:

def test_login(py: Pylenium):
    py.visit("https://the-internet.herokuapp.com/login")
    py.get("#username").type("tomsmith")
    py.get("#password").type("SuperSecretPassword!")
    py.get("button[type='submit']").submit()
    assert py.contains("You logged into a secure area!").should().be_visible()
PrevioussubmitNextuncheck

Last updated 2 years ago

πŸ‘