Skip to main content

Wait and Type

Wait for input elements to become available and interactive, then enter text content.

Basic Wait and Type

{
  "url": "https://example.com",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "input[name='search']",
      "text": "web scraping tools"
    }
  ]
}

Parameters

ParameterTypeRequiredDescription
typestringYesMust be "wait_and_type"
selectorstringYesCSS selector for the input element
textstringYesText to type into the element
timeoutintegerNoMax wait time in milliseconds (default: 10000)
clearbooleanNoClear existing text first (default: true)
delayintegerNoDelay between keystrokes in ms (default: 0)

Use Cases

Search Forms

Enter search queries:
{
  "url": "https://search-site.com",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "#search-input",
      "text": "artificial intelligence"
    },
    {
      "type": "wait_and_click", 
      "selector": "button[type='submit']"
    }
  ]
}

Login Forms

Fill authentication forms:
{
  "url": "https://app.com/login",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "input[name='username']",
      "text": "[email protected]"
    },
    {
      "type": "wait_and_type",
      "selector": "input[name='password']", 
      "text": "secure-password"
    },
    {
      "type": "wait_and_click",
      "selector": "button[type='submit']"
    }
  ]
}

Contact Forms

Fill multi-field forms:
{
  "url": "https://company.com/contact",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "input[name='name']",
      "text": "John Smith"
    },
    {
      "type": "wait_and_type",
      "selector": "input[name='email']",
      "text": "[email protected]"
    },
    {
      "type": "wait_and_type",
      "selector": "textarea[name='message']",
      "text": "I'm interested in your services."
    }
  ]
}

Advanced Options

Human-like Typing

Add realistic delays between keystrokes:
{
  "type": "wait_and_type",
  "selector": "#chat-input",
  "text": "Hello, I need help with my order",
  "delay": 50
}

Preserve Existing Text

Don’t clear existing content:
{
  "type": "wait_and_type",
  "selector": ".editor-input",
  "text": " additional content",
  "clear": false
}

Extended Timeout

Wait longer for slow-loading forms:
{
  "type": "wait_and_type",
  "selector": ".dynamic-form input",
  "text": "form data",
  "timeout": 20000
}

Input Types

Text Input

{
  "type": "wait_and_type",
  "selector": "input[type='text']",
  "text": "Sample text"
}

Email Input

{
  "type": "wait_and_type",
  "selector": "input[type='email']", 
  "text": "[email protected]"
}

Password Input

{
  "type": "wait_and_type",
  "selector": "input[type='password']",
  "text": "SecurePassword123!"
}

Textarea

{
  "type": "wait_and_type",
  "selector": "textarea",
  "text": "Multi-line text content\\nWith line breaks\\nAnd paragraphs"
}

Number Input

{
  "type": "wait_and_type",
  "selector": "input[type='number']",
  "text": "12345"
}

Special Characters

Line Breaks

{
  "type": "wait_and_type",
  "selector": "textarea",
  "text": "First line\\nSecond line\\nThird line"
}

Tab Characters

{
  "type": "wait_and_type",
  "selector": ".code-editor",
  "text": "function example() {\\n\\treturn true;\\n}"
}

Special Keys

Use escape sequences for special keys:
{
  "type": "wait_and_type",
  "selector": "input",
  "text": "text\\t\\n"  // text + tab + enter
}

Error Handling

Element Not Found

{
  "status": "error",
  "error": "ELEMENT_NOT_FOUND",
  "message": "Input element with selector 'input.missing' not found",
  "selector": "input.missing"
}

Element Not Editable

{
  "status": "error",
  "error": "ELEMENT_NOT_EDITABLE",
  "message": "Element is not editable (disabled or readonly)",
  "selector": "input[disabled]"
}

Timeout Exceeded

{
  "status": "error",
  "error": "TIMEOUT_EXCEEDED",
  "message": "Input element did not become editable within 10000ms"
}

Complex Form Workflows

Multi-Step Form

{
  "url": "https://multi-step-form.com",
  "actions": [
    // Step 1: Personal Info
    {
      "type": "wait_and_type",
      "selector": "input[name='firstName']",
      "text": "John"
    },
    {
      "type": "wait_and_type", 
      "selector": "input[name='lastName']",
      "text": "Doe"
    },
    {
      "type": "wait_and_click",
      "selector": "button.next-step"
    },
    
    // Step 2: Contact Info
    {
      "type": "wait_and_type",
      "selector": "input[name='email']",
      "text": "[email protected]"
    },
    {
      "type": "wait_and_type",
      "selector": "input[name='phone']", 
      "text": "(555) 123-4567"
    }
  ]
}

Form with Validation

{
  "url": "https://validated-form.com",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "input[name='email']",
      "text": "invalid-email"
    },
    {
      "type": "wait_for_selector",
      "selector": ".error-message"
    },
    {
      "type": "wait_and_type",
      "selector": "input[name='email']",
      "text": "[email protected]"
    }
  ]
}

Dynamic Form Fields

{
  "url": "https://dynamic-form.com",
  "actions": [
    {
      "type": "wait_and_click",
      "selector": ".add-field-btn"
    },
    {
      "type": "wait_and_type",
      "selector": ".dynamic-field:last-child input",
      "text": "Dynamic field value"
    }
  ]
}

Best Practices

Selector Specificity

// Good - specific selector
{
  "type": "wait_and_type",
  "selector": "input[data-testid='search-query']",
  "text": "search term"
}

// Avoid - too generic
{
  "type": "wait_and_type",
  "selector": "input",
  "text": "text"
}

Realistic Typing Speed

// Human-like typing for stealth
{
  "type": "wait_and_type",
  "selector": "#user-input",
  "text": "realistic user input",
  "delay": 75
}

// Fast typing for efficiency
{
  "type": "wait_and_type", 
  "selector": "#bulk-input",
  "text": "bulk data entry",
  "delay": 0
}

Form Validation Handling

{
  "url": "https://form-site.com",
  "actions": [
    {
      "type": "wait_and_type",
      "selector": "input[required]",
      "text": "required field value"
    },
    // Wait for validation to complete
    {
      "type": "wait",
      "duration": 1000
    },
    {
      "type": "wait_and_click",
      "selector": "button[type='submit']"
    }
  ]
}

SDK Examples

Node.js

const result = await client.scrape({
  url: 'https://example.com',
  actions: [
    {
      type: 'wait_and_type',
      selector: 'input[name="search"]',
      text: 'web scraping',
      delay: 50
    }
  ]
});

Python

result = client.scrape({
    'url': 'https://example.com',
    'actions': [
        {
            'type': 'wait_and_type',
            'selector': 'input[name="search"]',
            'text': 'web scraping',
            'delay': 50
        }
    ]
})

Security Considerations

Sensitive Data

  • Never hardcode passwords in your scraping scripts
  • Use environment variables for sensitive inputs
  • Consider data encryption for stored credentials
  • Implement secure credential management

Example with Environment Variables

{
  type: 'wait_and_type',
  selector: 'input[name="password"]',
  text: process.env.USER_PASSWORD
}