Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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 ^
    mendhak
    @mendhak

    Thanks, that was it just had to add the double quotes around the ${}. I got it working like so

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

    The g() version also worked.

    Peter Tesler
    @vptes1
    Awesome!
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    I was hoping to get this running in Linux but I am running into problems.
    Has anyone been able to get this running in Linux and does anyone have advice?
    RoyceTheBiker
    @RoyceTheBiker_gitlab

    I got half working. I get an error about only supporting Chrome 80. I have version 79, and testing with firefox gives a JS error.

    Open Chrome
    Open Firefox
    
        Navigate to 'google.com'
    
            Type 'hello world[enter]' into 'textbox'

    I will try again later.

    Craig Waite
    @craigvl
    Any way to change the EF text compare from a "contains" to a "equals"? can you pass a regex?
    Craig Waite
    @craigvl
    I have answered my own question I think, at the moment it is using 'contains' would need to change to 'contains exact' elementfinder line 219
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    image.png
    I forked the project to add Docker setup files. I ran SmashTest in Ubuntu and got the same errors. I would really like a workaround for this. I understand that the project does not have official support for Linux. What would it take to make it work?
    Peter Tesler
    @vptes1
    Try upgrading to the latest version of nodejs
    @RoyceTheBiker_gitlab ^
    Craig Waite
    @craigvl
    @RoyceTheBiker_gitlab I had the same issue and the fix was as Peter has suggested to update node version
    RoyceTheBiker
    @RoyceTheBiker_gitlab
    What is the version number you tried with? I have tried with 9, 10 and 13.8.
    Open Chrome
    WebDriverError: unknown error: Chrome failed to start: exited abnormally.   [/root/sample.smash:1]
      (unknown error: DevToolsActivePort file doesn't exist)
      (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
    Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
    System info: host: 'ubuntu', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.0-28-generic', java.version: '11.0.6'
    Driver info: driver.version: unknown
    remote stacktrace: #0 0x55e0276927a9 <unknown>
    
        at Object.checkLegacyResponse (/root/.nvm/versions/node/v13.8.0/lib/node_modules/smashtest/node_modules/selenium-webdriver/lib/error.js:585:15)
        at parseHttpResponse (/root/.nvm/versions/node/v13.8.0/lib/node_modules/smashtest/node_modules/selenium-webdriver/lib/http.js:554:13)
        at Executor.execute (/root/.nvm/versions/node/v13.8.0/lib/node_modules/smashtest/node_modules/selenium-webdriver/lib/http.js:489:26)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)