Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    If I go into REPL and run each command manually one at a time it stays connected and Firefox stays open.
    Can the --debug option help here? It wants a hash but I don't know what to do with that.
    Peter Tesler
    @vptes1
    You should either indent each of the last 4 lines or put a .. on top of the {{username}} line. You're creating four different branches here.
    Open Firefox
    
        Navigate to 'localhost:4200'
            ..
            {{username}} = 'admin'
            {{password}} = '12345'
            Type {{username}} into 'input[name=username]'
            Type '{{password}}[enter]' into 'input[name=password]'
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    Righ. I forgot about that. I will change it and try again.
    Peter Tesler
    @vptes1
    Or, to make it cleaner...
    ..
    Open Firefox
    Navigate to 'localhost:4200'
    {{username}} = 'admin'
    {{password}} = '12345'
    Type {{username}} into 'input[name=username]'
    Type '{{password}}[enter]' into 'input[name=password]'
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    It did not like the .., complained about Error: You cannot have a .. line without anything directly below [:1]. The tab in worked but the shell still terminates.
    Peter Tesler
    @vptes1
    I'd just run the test normally (put it in a .smash file, and run it with smashtest --test-server=http://localhost:4444/wd/hub, no -r flag). If you want to debug a particular step using the REPL, put a ~ next to it.
    You wouldn't put .. or indents into the REPL directly...only single-line commands
    So when you're using .load it just regurgitates a bunch of previously-typed-in lines directly into the REPL, and that doesn't always work
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    What is a good way to deal with CAPTCHA or MFA? I have control over the full stack. Is there a way to call an external command or API? I don't want to disable them or set them to fixed answers, I would like to call an API that will return what the input for these fields should be.
    Peter Tesler
    @vptes1
    Any nodejs code can go into a code block. You can do it from there.
    Peter Tesler
    @vptes1
    Version 1.7 is out!
    id7digital
    @id7digital
    Hi guys, do you know if there is a way of handling popups using smashtest, as in adding text to them using smashtest
    Peter Tesler
    @vptes1
    HTML popups or alerts?
    id7digital
    @id7digital
    alerts
    Peter Tesler
    @vptes1
    There are built-in steps for handling alerts. If there isn't one for typing in text, you can just make a custom one (with code block and webdriverjs code inside)
    You can access that WebDriver object in a code block via browser.driver
    Your code will be something like
    * Type {{text}} into alert {
        await browser.driver.switchTo().alert().sendKeys(text);
    }
    Then
    Type 'something' into alert
    yea looks like there isnt a built-in one. So try using this one.
    id7digital
    @id7digital
    thanks, is there a way around 2 text boxes in an alert?
    Peter Tesler
    @vptes1
    Not sure. You'd have to check the webdriverjs documentation on that.
    Peter Tesler
    @vptes1
    If webdriverjs doesn't allow you to switch between the two, I wonder if sending a tab key to the first box will do the trick
    id7digital
    @id7digital
    thanks, will give it a try for the first box see what happens :)
    mendhak
    @mendhak
    Just spotted API testing in the docs. Do you think there is any way to make use of OAuth signing when writing an API test?
    Peter Tesler
    @vptes1
    I think you can just pass in the same oauth stuff you'd pass to request.post(), etc. since the smashtest api functions are just a wrapper on top of request
    mendhak
    @mendhak

    Thanks, just tried it and it was as you said, a matter of putting the objects in the right place

     Make a request $ {
            await post( 
                { 
                    url: 'https://example.auth0.com/oauth/token', 
                    body: '{"client_id":"aaaaaaaa","client_secret":"bbbb","audience":"1234","grant_type":"client_credentials"}',
                    headers: { 'content-type': 'application/json' }
                });
        }
    
            Verify the response { 
                console.log(response.response.body.access_token);
            }

    Might be an auth0 thing, I had to use response.response to get to the body.

    Peter Tesler
    @vptes1
    Do you have the latest version? You should be able to get to it via just response, as opposed to response.response (this was a fix in one of the most recent versions)
    Also, I wonder if you can get away with not quoting the body, i.e., passing in regular json
    mendhak
    @mendhak
    Ah I updated to lastest version and response.body.access_token is now working. Using a regular JSON for body didn't work, but that's OK.

    Follow up q - how can I assign the response to a variable? I think I'm missing something fundamental here.

    This works: l('access_token', response.body.access_token);

    This doesn't work: {myvariable} = response.body.access_token - it results in SyntaxError: Unexpected token =

    Peter Tesler
    @vptes1
    {variable} = only works when it's at the start of a step. l() or g() works inside a code block.
    mendhak
    @mendhak
    That was it, thanks again @vptes1 - I'm now using {variable} = Get My Access Token as a function at the beginning then passing it as an Authorization header in subsequent API calls. Just what I needed
    Peter Tesler
    @vptes1
    👍
    id7digital
    @id7digital
    Hi guys, quick question, do you know if there is a way in smashtest to do clicks on elements of on unordered list. So i can specify the selector and it will just click on all li items, or would i need to write javascript for this?
    Peter Tesler
    @vptes1
    You mean multiple clicks, one on each li? Yeah you'd either need multiple Click steps, or implement a custom code block function in js
    id7digital
    @id7digital
    thanks @vptes1
    Craig Waite
    @craigvl
    Peter, was easy enough to hack together some code that allows screenshot compare to happen, using pixelmatch to do the compare and added two new parameters one to say "capture base line shots" and another to say "compare" , if difference is found creates a diff file, don't think that this is worth adding to core but just wanted to let you know that it was not to hard
    Peter Tesler
    @vptes1
    👍
    Craig Waite
    @craigvl

    Created a new project and only has one file smash file with:

    Open Chrome
    
        Desktop
    
            Navigate to 'www.google.com'

    If I run without --recursive , only creates one branch, if run with --recursive creates 16 branches?

    Peter Tesler
    @vptes1
    I cannot reproduce (version 1.7.0). It creates 1 branch in both cases. Check what other .smash files exist in the directory structure below.
    Craig Waite
    @craigvl
    none, but will try and see if I can find one
    ok so that is the issue picking up from smashtest folder in node_modules folder
    mendhak
    @mendhak

    Can a props contain a variable? eg, something like this

    Setup Props {
        props({
            'my button': `contains {my_global_variable}`
        });
    }
    
        Verify 'my button' is visible

    I've tried with and without the {}, with and without "{}".

    Peter Tesler
    @vptes1
    Since props is just js, use something like contains ${myvariable}
    Or contains ${g('my variable')}
    Make sure the variable is already set by the time that line is executed
    @mendhak ^