kamalarieff / automate

Python, Selenium, etc. i.e. any form of automation
0 stars 0 forks source link

Getting started

Required installations

chromedriver

$ brew install chromedriver

phantomjs

$ brew install phantomjs

Google sheets API

$ pip install --upgrade google-api-python-client

Input files

Config

Example

{
    "config":[
    {
        "url":"http://www-schibstedclassifiedmedia.mudah.my",
        "repeat":"2"
    }
    ]
}

Assert

Browser

Actions

Example

{
    "1":[
    {
        "type":"link",
        "element":"LINK_TEXT",
        "attr":"INSERT AD"
    },
    {
        "type":"dropdown",
        "element":"ID",
        "attr":"category_group",
        "value":"7020"
    },
    {
        "wait":"2",
        "type":"image",
        "element":"ID",
        "attr":"image_0",
        "value":"/Users/kamalarieff/Pictures/pp.jpeg"
    },
    {
        "type":"text",
        "element":"ID",
        "attr":"job_summary",
        "value":"TEST FOR NEW JOB AI FORM"
    },
    {
        "type":"checkbox",
        "element":"ID",
        "attr":"language_skill",
        "value":"1",
        "multiple":"0"
    },
    {
        "type":"checkbox",
        "element":"ID",
        "attr":"experience_offer3"
    },
    {
        "type":"button",
        "element":"ID",
        "attr":"due_date"
    },
    {
        "type":"button",
        "element":"XPATH",
        "attr":"//span[text()='Next']"
    },
    {
        "type":"dropdown",
        "element":"ID",
        "attr":"region",
        "value":"9"
    }
    ],
    "assert":[
    {
        "value":"jobsnew1@gmail.com"
    }
    ],
    "browser":[
    {
        "url":"https://www.facebook.com"
    }
    ]
}

Converting from old format to new format

$ python modify_input_files.py <inputfile>.json

How to run

Activate your virtualenv

$ source ~/virtualenv/bin/activate

Setup

Actions

Config

Browser

Running the script

Only one input file

$ python automate-command-line.py -c config_file.json -i input_file.json

More than one input files

Two ways to insert
  1. Separate by commas
$ python automate-command-line.py -c config_file.json -i input_file1.json,input_file2.json
  1. Multiple -i flags
$ python automate-command-line.py -c config_file.json -i input_file1.json -i input_file2.json

Google Sheets

General
Setup
Example
$ python automate-command-line.py --start-cell=A15 --end-cell=C15

Helpful references