Oblisk is a simple web automation script runner based on Selenium WebDriver. It allows you to automate browser actions using a custom scripting language with commands similar to SQL. You can input commands through an external .obl
file, via the command line, or from a URL.
- Navigate to URLs
- Click elements
- Input text into elements
- Wait for elements
- Extract text from elements
- Press Enter or Tab keys in elements
- Python 3.x
- Google Chrome browser
- ChromeDriver (make sure the ChromeDriver version matches your Chrome browser version)
-
Clone the repository or download the
Oblisk.py
file. -
Install the required Python packages using pip:
pip install selenium requests
-
Make sure
chromedriver
is in your PATH or place it in the same directory asOblisk.py
.
You can use Oblisk in three different ways:
Create a .obl
file with your commands. Here is an example script.obl
file:
NAVIGATE TO 'https://example.com/login'
INPUT 'testuser' INTO element WHERE id='username'
INPUT 'password123' INTO element WHERE id='password'
CLICK element WHERE id='submit'
WAIT FOR element WHERE id='welcome-message' TIMEOUT 10 SECONDS
EXTRACT text FROM element WHERE id='welcome-message' INTO welcome_text
PRESS ENTER IN element WHERE id='username'
PRESS TAB IN element WHERE id='username'
Run the script using the following command:
python Oblisk.py --file path/to/script.obl
Pass the commands as a single string, separated by semicolons or new lines:
python Oblisk.py --cmd "NAVIGATE TO 'https://example.com/login'; INPUT 'testuser' INTO element WHERE id='username'; INPUT 'password123' INTO element WHERE id='password'; CLICK element WHERE id='submit'"
Provide a URL that contains the commands in plain text:
python Oblisk.py --url "https://example.com/commands.txt"
NAVIGATE TO '<url>'
: Navigates to the specified URL.CLICK element WHERE <selector_type>='<value>'
: Clicks the element identified by the selector.INPUT '<text>' INTO element WHERE <selector_type>='<value>'
: Inputs the specified text into the element.WAIT FOR element WHERE <selector_type>='<value>' TIMEOUT <seconds>
: Waits for the element to appear within the specified timeout.EXTRACT text FROM element WHERE <selector_type>='<value>' INTO <variable_name>
: Extracts text from the element and stores it in the specified variable.PRESS ENTER IN element WHERE <selector_type>='<value>'
: Presses the Enter key in the specified element.PRESS TAB IN element WHERE <selector_type>='<value>'
: Presses the Tab key in the specified element.
To add a new command, follow these steps:
-
Define the Command Method: Create a new method in the
WebAutomation
class to handle the new command. The method should accept a list of arguments.def new_command(self, args): # Your implementation here pass
-
Log the Command: Add logging to the new command method.
def new_command(self, args): self.log_command('new_command', args) # Your implementation here pass
-
Update the Commands Dictionary: Add the new command to the
commands
dictionary in the__init__
method of theWebAutomation
class.self.commands = { 'navigate to': self.navigate_to, 'click element where': self.click_element, 'input into element where': self.input_text, 'wait for element where': self.wait_for_element, 'extract text from element where': self.extract_text, 'press enter in element where': self.press_enter_key, 'press tab in element where': self.press_tab_key, 'new command': self.new_command # Add your new command here }
-
Parse the Command: Ensure that the
parse_command
method can recognize and execute the new command.def parse_command(self, command): command = command.strip().lower() for key in self.commands: if command.startswith(key): args = re.findall(r'\'(.*?)\'', command[len(key):]) self.commands[key](args) return raise ValueError(f"Unsupported command: {command}")
Here is an example usage:
python Oblisk.py --file example.obl
Where example.obl
contains:
NAVIGATE TO 'https://example.com/login'
INPUT 'user' INTO element WHERE id='username'
INPUT 'pass' INTO element WHERE id='password'
CLICK element WHERE id='submit'
WAIT FOR element WHERE id='dashboard' TIMEOUT 10 SECONDS
EXTRACT text FROM element WHERE id='welcome-message' INTO welcome_text
This project is licensed under the MIT License.