#selenium

/

      • leb0x joined the channel
      • mwinteringham joined the channel
      • mwinteringham has quit
      • neoncontrails joined the channel
      • leb0x
        var webdriver = require ('selenium-webdriver'), { describe, it, after, before } = require('selenium-webdriver/testing'); By = webdriver.By, until = webdriver.until; var driver = new webdriver.Builder().forBrowser('chrome').build(); driver.manage().window().setSize(1280,1000).then(function() { driver.get('http://www.hannaandersson.com/b...; }) driver.manage().timeouts().implicitlyWait(10000)
      • I'
      • I've pasted my code here. Sometimes when I run this I get the desired response other times I get no value or I get that the element doesn't exist I don't understand why it works and sometimes it doesn't
      • neoncont_ joined the channel
      • hazmeister-sl
        firstly, some of the selectors you are using seem kind of brittle: driver.findElement(By.css(‘body > div.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front.news-content-modal.copy > div.ui-dialog-titlebar.ui-widget-header.ui-corner-all.ui-helper-clearfix > button > span.ui-button-icon-primary.ui-icon.ui-icon-closethick’)).click();
      • if any of those elements are missing, or are added by javascript, you could end up in a race condition
      • leb0x
        I'm still kind of new to selenium and I don't know a better way outside just selecting the element and doing the copy xpath. This website is done via demandware and is very complicated for elements
      • hazmeister-sl
        try this tutorial for learning about CSS Selectors
      • leb0x
        I have done that before. I guess I just get lost on this website because things are so deep and confusing. Could you tell me how you'd select one or two of those selectors. That would help me understand a bit more
      • hazmeister-sl
        so, for the modal, I would use `[aria-describedby="QuickViewDialog"]`
      • it should be fairly unique
      • leb0x
        Would that select all of the quickbuys?
      • Selenium-Github
        [13selenium] 15jleyba closed pull request #4959: Fixes #2888 - Retry on network error (06master...06issue-2888) 02https://git.io/vFvEQ
      • converge has quit
      • [13selenium] 15jleyba pushed 1 new commit to 06master: 02https://git.io/vFL0Y
      • 13selenium/06master 1452a6d68 15Mark Christian: node/selenium-webdriver: increase maximum number of portprober attempts from 10 -> 100 (#4932)...
      • hazmeister-sl
        that was for the modal that pops up after click Quick Buy
      • if you want the quick buy button, why not `.quickbuy-btn`
      • ajit joined the channel
      • leb0x
        If I was willing to pay you to help me write tests and show me the best selectors for this one quick buy to teach me best practices would you be interested in that?
      • hazmeister-sl
        I have a full time job already, but you can always seek help on here
      • it’s busier during the week
      • leb0x
        I understand. I'm a junior web dev and I was told if I can write some tests for this I'd get the job. I just never touched selenium till yesterday
      • hazmeister-sl
        it might be worth finding an online course or buying a book
      • I got started with java
      • but it looks like you are using node?
      • leb0x
        yes I'm using node
      • I had a tree house guide on node
      • but it wasn't very long. Very basic
      • hazmeister-sl
        You might want to try this: https://seleniumguidebook.com
      • I would suggest checking a sample chapter before buying
      • he also offers some free tips via a newsletter
      • leb0x
        oh wow 250
      • If I get the job ill do it 100%
      • hazmeister-sl
        that’s the version with video- there are cheaper options on there where you get just the book
      • leb0x
        They wanted a basic qa and junior web dev. They are very interested in eventually automating everything. I've spent all day yesterday just getting it to open the quick buy box
      • hazmeister-sl
        there’s also a sample video on writing locators on there
      • thing is, you’ve jumped in with quite a complicated example there to start with
      • so you’re off to a good start
      • leb0x
        Thanks for the compliment. I will read his site and sign up. Now I just need to write tests for the stuff in that one quick buy.
      • So you mentioned `[aria-describedby="QuickViewDialog"]` how would I target the text "Skiers Sweater In Cotton & Merino" with that aria describer?
      • hazmeister-sl
        let’s start at the top
      • after you get the URL
      • you need to close that annoying popup
      • currently you do:
      • driver.sleep(1000); try { driver.findElement(By.css(‘body > div.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front.news-content-modal.copy > div.ui-dialog-titlebar.ui-widget-header.ui-corner-all.ui-helper-clearfix > button > span.ui-button-icon-primary.ui-icon.ui-icon-closethick’)).click(); } catch (error) { console.log(“There was an error closing popup ” + error) }
      • Orphis joined the channel
      • couple of tips here
      • first, avoid sleep(1000)
      • leb0x
        ok
      • hazmeister-sl
        you’ll want to avoid implicit waits too if you can help it
      • and you can make findign elements easier by looking within elements
      • so first thing I would do is find the modal that pops up
      • and stick it in a var
      • something like (forgive my javascript):
      • var newsModal = driver.findElement(By.css(‘’.news-content-modal));
      • then from there, you can find the close button
      • leb0x
        I tried the close button before
      • at least when you click it
      • it opens the hover menu when you click the x
      • and then it can't find the sweater or quick buy stuff
      • it was saying its there but isnt't there. Something like that. I tried to sendKey Escape and couldn't get that to work either
      • hazmeister-sl
        very challenging page!
      • if a sub menu is popping up when you close that modal, you need to use actions to move the cursor somewhere which won’t trigger the pop up
      • leb0x
        yeah man I've struggled all day yesterday just to get to open the quick buy.
      • so how would you target the close button inside this modal?
      • hazmeister-sl
        so, first find the modal:
      • var newsModal = driver.findElement(By.css(‘’.news-content-modal));
      • leb0x
        ok
      • hazmeister-sl
        then you can do: newsModal.findElement(By.css(“button[title=‘close’]“))
      • that way, it’s only looking for close buttons within the context of the modal, instead of the whole page
      • got it?
      • sugat-sl joined the channel
      • leb0x
        yeah
      • it found that element
      • so would we click it?
      • btw this is so helpful. idk why I didn't think of finding a whole modal then finding stuff inside it like this
      • sugat-sl
        Selenium Docker Firefox - Firefox 56 gives "Your connection is not secure" error message when trying to run test. And test fails immediately. Any Idea ?
      • I have selenium version 3.0.1
      • leb0x
        see when I tried to find the button again I get the no such element Unable to locate element: {"method":"css selector","selector":"button[title='close']"} (Session info: chrome=61.0.3163.100)
      • it worked the first time
      • hazmeister-sl
        could be because that modal doesn’t appear immediately
      • leb0x
        I'm testing it in node right now
      • with the modal up
      • this is where I get frustrated with this. The first time I tried it it worked awesome
      • now I'm in the node terminal with the window open just entering the commands manually
      • I'm getting newsModal.findElement(By.css('button[title="close"]'));
      • NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"button[title="close"]"}
      • hazmeister-sl
        hmmm
      • and the modal is on screen?
      • because either I got the selector wrong
      • or its a timing problem
      • energizer joined the channel
      • leb0x
        modal is on screen for the 15% off
      • <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front news-content-modal copy" tabindex="-1" role="dialog" aria-describedby="dialog-container" aria-labelledby="ui-id-1" style="height: auto; width: 800px; top: 194px; left: 386px; display: block; z-index: 101;"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span id="ui-id-1" class="ui-dialog-title">&nbsp;</span><button type="butto
      • if I just type into terminal newsModal for the variable we set I get a bunch of stuff
      • this is why I've been going crazy one minute it works next minute it gives me these errors and idk why. The news modal is up on the screen in the testing envrioment
      • ajit has quit
      • Mush joined the channel
      • Mush
        hi
      • i have installed selenuim ide but i am getting error when I use selenium ide as
      • Url: chrome://selenium-ide/content/editor.js, line: 1007, column: 75
      • appreciating quick help or advise#
      • moshi has quit
      • hazmeister-sl
        @leb0x I should’ve used a capital C for close
      • leb0x
        let me try that
      • Anitha joined the channel
      • Anitha
        hi
      • moo-_- joined the channel
      • Anitha has quit
      • leb0x
        @hazmeister-sl I I was just able to grab the text with the method you showed me
      • var skiersQuick = driver.findElement(By.css('[aria-describedby="QuickViewDialog"]')); skiersQuick.findElement(By.css('[class="pdo-product-name is-desktop"]')); var text = skiersQuick.findElement(By.css('[class="pdo-product-name is-desktop"]')); text.getText().then(function (text) { console.log(text) });
      • kpschmidt joined the channel
      • hazmeister-sl
        :)
      • leb0x
        that bit you showed how to do a better job at selectors is huge for me
      • ty very much
      • now I'm going to try and get to the writing tests part lol
      • hazmeister-sl
        good luck!
      • kpschmidt has quit
      • Mush has quit
      • NOTICE: SeleniumHQ/selenium#2958 (master - 52a6d68 : Mark Christian): The build has errored.
      • NOTICE: Change view : https://github.com/SeleniumHQ/selenium/compare/83bdd7b2ed4e...52a6d68ca75f
      • NOTICE: Build details : https://travis-ci.org/SeleniumHQ/selenium/builds/294525408
      • converge joined the channel
      • converge has quit
      • converge joined the channel
      • leb0x
        @hazmesiter-sl you mentioned waits are bad. How could I wait for the modal to pop up for the newsModal before it starts executing scripts to get away from the sleep
      • Selenium-Github
        [13selenium] 15jleyba pushed 4 new commits to 06master: 02https://git.io/vFL2j
      • 13selenium/06master 141ae127f 15Jason Leyba: [js] Remove non-standard capabilities (like elementScrollBehavior)...
      • 13selenium/06master 14acbdeee 15Jason Leyba: [js] Remove meaningless Safari options...
      • 13selenium/06master 14d79f1b1 15Jason Leyba: [js] Removed the deprecated driver.manage().timeouts()...
      • sugat-sl has quit
      • ajit joined the channel
      • leb0x has quit
      • converge has quit
      • hazmeister-sl has quit
      • neoncontrails joined the channel
      • bpascal joined the channel
      • bpascal1 joined the channel
      • bpascal has quit
      • NOTICE: SeleniumHQ/selenium#2959 (master - 6648015 : Jason Leyba): The build failed.
      • NOTICE: Change view : https://github.com/SeleniumHQ/selenium/compare/52a6d68ca75f...6648015ba949
      • NOTICE: Build details : https://travis-ci.org/SeleniumHQ/selenium/builds/294552327