+ All Categories
Home > Documents > Automated browser testing with Selenium and C#

Automated browser testing with Selenium and C#

Date post: 23-Feb-2016
Category:
Upload: melia
View: 103 times
Download: 0 times
Share this document with a friend
Description:
Automated browser testing with Selenium and C#. Darren Bruning @ dbruning. Going to cover:. Why browser automation? Why selenium? “Naked” selenium Selenium in a test framework: Kumara Kumara internals More Selenium goodness. Why browser automation?. Primarily for testing - PowerPoint PPT Presentation
Popular Tags:
27
Automated browser t esting with Seleniu m and C# Darren Bruning @dbruning
Transcript
Page 2: Automated browser testing with Selenium and C#

Going to cover:• Why browser automation?• Why selenium?• “Naked” selenium• Selenium in a test framework: Kumara• Kumara internals• More Selenium goodness

Page 3: Automated browser testing with Selenium and C#

Why browser automation?

• Primarily for testing• Maybe also to script boring repetitive tasks

Page 4: Automated browser testing with Selenium and C#

What is selenium?• There are lots of browsers• They all do similar things (go to websites, let you click on things)• There was no consistent API to automate them• Selenium 1: was javascripty, problematic• WebDriver project started at Google• Selenium 2 adopted WebDriver as preferred method to “drive”

browsers.

Page 5: Automated browser testing with Selenium and C#

WebDriver protocol• Uses HTTP as a transport• “Bindings” for different languages, emit HTTP calls• WebDriver “drivers” (servers) accept HTTP calls & actually drive the

browser

Page 6: Automated browser testing with Selenium and C#

What does Selenium API look like?

Page 7: Automated browser testing with Selenium and C#

Why not write tests directly against Selenium API?• Tests end up with lots of code• “business logic” gets obscured• Tests only readable by devs• Would be more value in the tests if they also served as

documentation• => BDD (Behaviour Driven Design)

Page 8: Automated browser testing with Selenium and C#

SpecFlow – feature files

Page 9: Automated browser testing with Selenium and C#

SpecFlow – behind the curtain

Page 10: Automated browser testing with Selenium and C#

SpecFlow is great and all but…• Yaaaay • test readability! • Feature documentation!

• Boo• Need plugin for Visual Studio• Can’t use refactoring tools• Becomes a pain to keep the feature file text in sync with the regex

Page 11: Automated browser testing with Selenium and C#

Enter the Kumara!• Nee Calcot• Given – when –then syntax• Given(List<ICondition>)• When(List<Action>)• Then(List<ICondition>)• It’s still just code, but it’s

very readable (maybe even by a BA? Or tester?)

Page 12: Automated browser testing with Selenium and C#

ICondition

Page 13: Automated browser testing with Selenium and C#

Wait, how can a condition satisfy itself???

Page 14: Automated browser testing with Selenium and C#

ActionBasedCondition implements ICondition

Page 15: Automated browser testing with Selenium and C#

Example of an ActionBasedCondition

Page 16: Automated browser testing with Selenium and C#

… and another one with preconditions

Page 17: Automated browser testing with Selenium and C#

So basically, with Kumara:• You define some “Root Nouns”

(the things you interact with in a test)

• You create some IConditions on those root nouns

• You write tests using those conditions

Page 18: Automated browser testing with Selenium and C#

How does Kumara use WebDriver?

Page 19: Automated browser testing with Selenium and C#

Commonly, by CSS:

Page 20: Automated browser testing with Selenium and C#

Then your tests can be all like…

Page 21: Automated browser testing with Selenium and C#

The awesomest thing about Selenium is…

Page 22: Automated browser testing with Selenium and C#

Review past tests, watch videos:• https://saucelabs.com/tests/69f48decbb234e3b8adadf2a3205eebe

Page 23: Automated browser testing with Selenium and C#

Run in any combination of OS and browser

Page 24: Automated browser testing with Selenium and C#

Also awesome: PhantomJS

• Very fast!• Runs locally, so less network latency for WebDriver calls,

bloating out the test runtime

Page 25: Automated browser testing with Selenium and C#

Build it into your CI flow, for early feedback

Page 26: Automated browser testing with Selenium and C#

Questions?

Page 27: Automated browser testing with Selenium and C#

Recommended