autologin script

Ranus's Avatar


28 Sep, 2017 03:58 PM

I recently discover your project and it seems really powerfull. However, I have a problem when I'm trying to connect my website.
The authentification require 3 inputs and a click after each one is filled.

I have tried 3 scripts (2 rb and 1js) and I think this one (js) works better :

document.getElementById('input1').value = '123456';
document.getElementById('input2').value = '1234';
document.getElementById('input3').value = 'abcd';

It seems to work but the check pattern match on error page not on home. When I log in from my browser, I go throught 1 first page ( which check password, ... and it normally throw me on a second page (

I think the check option doesn't let time for redirection.

Have you got an idea about that ?


  1. Support Staff 1 Posted by Tasos Laskos on 05 Oct, 2017 10:36 AM

    Tasos Laskos's Avatar

    Javascript doesn't work like that, that script operates within the browser as if it was part of the webpage, so once the page changes the script is no longer there.
    You need to switch to a Ruby login script, that operates on the browser level and will let you navigate accordingly.

  2. 2 Posted by Ranus on 05 Oct, 2017 11:02 AM

    Ranus's Avatar

    Hi, thank you for your answer.
    I've tried with Ruby script but can't figure how to make it work. For now I can pass arguments an click but it seems that the can't validate all of it.

    # encoding: utf-8
    browser.goto 'https://url/'
    form = browser.form( name: 'myForm' )
    form.text_field( id: 'login' ).set 'myLogin'
    btn = browser.button( id: 'btn' )
                    # You can also configure the session check from the script, dynamically,
                    # # if you don't want to set static options via the user interface.
    framework.options.session.check_url     = 'https://url/'
    framework.options.session.check_pattern = 'Home Page'

    I use browser.execute_script because password is on readonly.

    Have you got an other idea ?

  3. Support Staff 3 Posted by Tasos Laskos on 13 Oct, 2017 09:23 AM

    Tasos Laskos's Avatar

    Can you try avoiding JS at all? Use only the Watir interface and see if that makes any difference.
    Btw, without direct access it's basically impossible for me to know what's going on in these cases.

  4. 4 Posted by Ranus on 13 Oct, 2017 03:02 PM

    Ranus's Avatar

    Yes, I can avoid JS I succeded with PostMan.
    I need to call first page with GET to get cookie,
    Second in POST to pass datas

    I tried with this kind of script but doesn't seems to work.

        parameters: {},
        mode:           :sync,
        update_cookies: true
    response = '',
        parameters:     {
        mode:           :sync,
        update_cookies: true
    framework.options.session.check_url = to_absolute( response.headers.location, response.url )
    framework.options.session.check_pattern = 'Welcome'

    I'm sorry but developpment versions are not available on internet and we can't test on production version.

    Thank you for your help

  5. 5 Posted by Ranus on 20 Oct, 2017 01:17 PM

    Ranus's Avatar

    Hi, I've finnally succeded with a Ruby script.
    I realized that could be reachwith a post call, so my script is like this :'',
        mode:           :sync,
        update_cookies: true
    framework.options.session.check_url = ''
    framework.options.session.check_pattern = 'Welcome'
    framework.session.check_options = {
        method:     :post,
        parameters: {

    Thank you for your help and your project :)

  6. Ranus closed this discussion on 20 Oct, 2017 01:19 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac