3

Currently I manually verify events being sent and received in the console by opening the dev tools in chrome. The testing is going to scale up and be repetitive soon. Any idea on how I could possibly automate this? My skill set is basic Java and Selenium.

  • can you be a little more specific about the context ? which events ? why chrome ? – Rsf Feb 19 '18 at 9:15
  • Please elaborate 'events'. – Vishal Aggarwal Feb 19 '18 at 11:52
  • JavaScript can be executed when an event occurs, like when a user clicks on an HTML element. I am testing a game and there is a new event that we send call "start_game" when the player clicks start which can be viewed in dev tools using chrome. The reason I am using chrome is because that is where players primarily play our games. w3schools.com/js/js_htmldom_events.asp – Rick Rosario Feb 20 '18 at 15:30
  • Do you want to verify on UI level or on unit level? If just want to validate app logic on user level then use selenium for browser level test automation.I would recommend using Protractor(Selenium). – Vishal Aggarwal Feb 25 '18 at 19:34
  • Yes but I havent seen how to test an event using selenium – Rick Rosario Feb 26 '18 at 20:23
0

You can try using tools like Browser Mob Proxy.

Also you can verify using event listeners as listed here.

  • 1
    please include content in your answer as links can suffer from link rot and then your answer becomes you can use tools and verify using event listeners please elaborate further – Malachi Feb 21 '18 at 18:52
0

Looking at your comment I think using the JavascriptExecutor might solve your problem.

You can add your own listener to the same event to set a boolean value if the event is fired or, much easier, ask a dev to attach one to the window object which you can request. This of course needs you to broaden your skillset to include Javascript.

If you just want to see if a request goes out you can easily look it up in the selenium logs. Just something as easy as:

public Boolean requestsWork(){
    LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
    for (LogEntry entry : logEntries) {
        if(
        entry.getMessage().matches("\w* [4-5][\d]{2} \w*")) return false;
    }
 return true;
 }

This should return false as soon as any request responds within the 400 or 500 range (thought the regex might still need some fine tuning).

-1

Basically, this should be possible. If you can manually discover, that "events being broadcasted" (whatever that means), it should be possible by Selenium as well. Selenium is using the very same access to the browser as Chrome Dev tools and you can do similar things. What you can do with Dev tools would be possible with Selenium and javaScript snippets as well.

Please, improve the description of how do you recognize in Chrome dev tools, that "events being broadcasted". Then we can further help you.

  • w3schools.com/js/js_htmldom_events.asp. I am testing a game and there is a new event that we send call "start_game" when the player clicks start which can be viewed in dev tools using chrome. The reason I am using chrome is because that is where players primarily play our games – Rick Rosario Feb 20 '18 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.