WebTester project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

WebTester project

Nicolas Anquetil

Hi all,

I developped a first version of a WebTestCase class.

It uses SUnit and Zinc to get pages from the internet and test some
conditions on them.

The main work is actually to offer higher level search facilities
inspired from what I saw in Selenium

There is an example, that logs in and out of Github (and checks that we
logged in and out)

---
testLoginAndOutOfGitHub
     | node |
     self defaultUrl: 'http://github.com/'.
     self getDefaultUrl.

     self assert: (self searchString: 'Sign in') notNil.
     self clickLinkValue: 'Sign in'.

     self assert: (self searchString: 'Sign in to GitHub') notNil.
     "5 fields to inform for login
      3 of them have values inside the login page: commit, utf8,
authenticity_token"
     self enter: user forName: 'login'.
     self enter: pass forName: 'password'.
     self enterDefaultValueForName: 'commit'.
     self enterDefaultValueForName: 'utf8'.
     self enterDefaultValueForName: 'authenticity_token'.
     "bug in the page, there is a </form> before the real <form ...>"
     node := self searchNodeTag: 'form' afterNode: (self searchNodeTag:
'form').
     self submitForm: node.

     "similar for signout, submit a form with 2 default values"
     node := self searchFormOwning: (self searchString: 'Sign out').
     self enterDefaultValueForName: 'utf8'.
     self enterDefaultValueForName: 'authenticity_token'.
     self submitForm: node.

     "we are out"
     self assert: (self searchString: 'Sign in') notNil.
---

No configOf or Catalog yet. I am too lazy

can be found at:

MCSmalltalkhubRepository
     owner: 'nicolasAnquetil'
     project: 'WebTest'
     user: ''
     password: ''


nicolas

--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod


Reply | Threaded
Open this post in threaded view
|

Re: WebTester project

Max Leske
Are you aware of the work that Johan did on Parasol (https://github.com/SeasideSt/Parasol)?

Max

On 25 Jun 2017, at 16:45, Nicolas Anquetil <[hidden email]> wrote:


Hi all,

I developped a first version of a WebTestCase class.

It uses SUnit and Zinc to get pages from the internet and test some conditions on them.

The main work is actually to offer higher level search facilities inspired from what I saw in Selenium

There is an example, that logs in and out of Github (and checks that we logged in and out)

---
testLoginAndOutOfGitHub
   | node |
   self defaultUrl: 'http://github.com/'.
   self getDefaultUrl.

   self assert: (self searchString: 'Sign in') notNil.
   self clickLinkValue: 'Sign in'.

   self assert: (self searchString: 'Sign in to GitHub') notNil.
   "5 fields to inform for login
    3 of them have values inside the login page: commit, utf8, authenticity_token"
   self enter: user forName: 'login'.
   self enter: pass forName: 'password'.
   self enterDefaultValueForName: 'commit'.
   self enterDefaultValueForName: 'utf8'.
   self enterDefaultValueForName: 'authenticity_token'.
   "bug in the page, there is a </form> before the real <form ...>"
   node := self searchNodeTag: 'form' afterNode: (self searchNodeTag: 'form').
   self submitForm: node.

   "similar for signout, submit a form with 2 default values"
   node := self searchFormOwning: (self searchString: 'Sign out').
   self enterDefaultValueForName: 'utf8'.
   self enterDefaultValueForName: 'authenticity_token'.
   self submitForm: node.

   "we are out"
   self assert: (self searchString: 'Sign in') notNil.
---

No configOf or Catalog yet. I am too lazy

can be found at:

MCSmalltalkhubRepository
   owner: 'nicolasAnquetil'
   project: 'WebTest'
   user: ''
   password: ''


nicolas

--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod



Reply | Threaded
Open this post in threaded view
|

Re: WebTester project

Nicolas Anquetil

nope :-(

but it was fun anyway

nicolas

On 25/06/2017 16:48, Max Leske wrote:
Are you aware of the work that Johan did on Parasol (https://github.com/SeasideSt/Parasol)?

Max

On 25 Jun 2017, at 16:45, Nicolas Anquetil <[hidden email]> wrote:


Hi all,

I developped a first version of a WebTestCase class.

It uses SUnit and Zinc to get pages from the internet and test some conditions on them.

The main work is actually to offer higher level search facilities inspired from what I saw in Selenium

There is an example, that logs in and out of Github (and checks that we logged in and out)

---
testLoginAndOutOfGitHub
   | node |
   self defaultUrl: 'http://github.com/'.
   self getDefaultUrl.

   self assert: (self searchString: 'Sign in') notNil.
   self clickLinkValue: 'Sign in'.

   self assert: (self searchString: 'Sign in to GitHub') notNil.
   "5 fields to inform for login
    3 of them have values inside the login page: commit, utf8, authenticity_token"
   self enter: user forName: 'login'.
   self enter: pass forName: 'password'.
   self enterDefaultValueForName: 'commit'.
   self enterDefaultValueForName: 'utf8'.
   self enterDefaultValueForName: 'authenticity_token'.
   "bug in the page, there is a </form> before the real <form ...>"
   node := self searchNodeTag: 'form' afterNode: (self searchNodeTag: 'form').
   self submitForm: node.

   "similar for signout, submit a form with 2 default values"
   node := self searchFormOwning: (self searchString: 'Sign out').
   self enterDefaultValueForName: 'utf8'.
   self enterDefaultValueForName: 'authenticity_token'.
   self submitForm: node.

   "we are out"
   self assert: (self searchString: 'Sign in') notNil.
---

No configOf or Catalog yet. I am too lazy

can be found at:

MCSmalltalkhubRepository
   owner: 'nicolasAnquetil'
   project: 'WebTest'
   user: ''
   password: ''


nicolas

--
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod




-- 
Nicolas Anquetil -- MCF (HDR)
Project-Team RMod
Reply | Threaded
Open this post in threaded view
|

Re: WebTester project

Stephane Ducasse-3
Nicolas this is the one I mentioned that wraps selenium

On Sun, Jun 25, 2017 at 4:55 PM, Nicolas Anquetil
<[hidden email]> wrote:

> nope :-(
>
> but it was fun anyway
>
> nicolas
>
>
> On 25/06/2017 16:48, Max Leske wrote:
>
> Are you aware of the work that Johan did on Parasol
> (https://github.com/SeasideSt/Parasol)?
>
> Max
>
> On 25 Jun 2017, at 16:45, Nicolas Anquetil <[hidden email]>
> wrote:
>
>
> Hi all,
>
> I developped a first version of a WebTestCase class.
>
> It uses SUnit and Zinc to get pages from the internet and test some
> conditions on them.
>
> The main work is actually to offer higher level search facilities inspired
> from what I saw in Selenium
>
> There is an example, that logs in and out of Github (and checks that we
> logged in and out)
>
> ---
> testLoginAndOutOfGitHub
>    | node |
>    self defaultUrl: 'http://github.com/'.
>    self getDefaultUrl.
>
>    self assert: (self searchString: 'Sign in') notNil.
>    self clickLinkValue: 'Sign in'.
>
>    self assert: (self searchString: 'Sign in to GitHub') notNil.
>    "5 fields to inform for login
>     3 of them have values inside the login page: commit, utf8,
> authenticity_token"
>    self enter: user forName: 'login'.
>    self enter: pass forName: 'password'.
>    self enterDefaultValueForName: 'commit'.
>    self enterDefaultValueForName: 'utf8'.
>    self enterDefaultValueForName: 'authenticity_token'.
>    "bug in the page, there is a </form> before the real <form ...>"
>    node := self searchNodeTag: 'form' afterNode: (self searchNodeTag:
> 'form').
>    self submitForm: node.
>
>    "similar for signout, submit a form with 2 default values"
>    node := self searchFormOwning: (self searchString: 'Sign out').
>    self enterDefaultValueForName: 'utf8'.
>    self enterDefaultValueForName: 'authenticity_token'.
>    self submitForm: node.
>
>    "we are out"
>    self assert: (self searchString: 'Sign in') notNil.
> ---
>
> No configOf or Catalog yet. I am too lazy
>
> can be found at:
>
> MCSmalltalkhubRepository
>    owner: 'nicolasAnquetil'
>    project: 'WebTest'
>    user: ''
>    password: ''
>
>
> nicolas
>
> --
> Nicolas Anquetil -- MCF (HDR)
> Project-Team RMod
>
>
>
>
> --
> Nicolas Anquetil -- MCF (HDR)
> Project-Team RMod

Reply | Threaded
Open this post in threaded view
|

Re: WebTester project

Torsten Bergmann
Hi Nicolas,

you can also checkout:

  http://smalltalkhub.com/#!/~TorstenBergmann/WebDriver

This implements the JsonWireProtocol so it is not necessary to install Java/Selenium and is
(hopefully) a cleaner implementation together with tests. Pharo only.

Simple How to:
==============
 - The project is currently written and working for Windows platform (but will be
   platform independent later)

 - run

     Metacello new
         configuration: 'WebDriver';
         smalltalkhubUser: 'TorstenBergmann' project: 'WebDriver';
         load.

   to load the project and all dependencies

 - Download ChromeDriver.exe and put it into the image directory
   https://chromedriver.storage.googleapis.com/index.html?path=2.30/

   You can also set a different location in "WebDriver" -> "Settings"

 - in the World menu choose "WebDriver" -> "ChromeDriver" -> "Run Chrome Driver"

 - open a playground and run

     wd := WDWebDriver new.
     wd url: 'http://www.pharo.org'.
     wd screenshotForm inspect

  which should open a chrome window.

It's not yet finished but if you like you can help completing it.

Bye
T.

Reply | Threaded
Open this post in threaded view
|

Re: WebTester project

philippeback
Nicolas,

It is still nice to have a thing that helps with web pages testing and that does not requires external libraries in order to work (even if limited in abilities).

We have got Soup etc, but I have also been using this:

https://github.com/ericchiang/pup

and it is super powerful for scraping data.

If one could wrap or port or remix it with Soup in Pharo it would be super cool.

(let's dream and we also get a jq wrapper and all of it in Scale... > students someone?)

Phil




On Tue, Jun 27, 2017 at 10:51 AM, Torsten Bergmann <[hidden email]> wrote:
Hi Nicolas,

you can also checkout:

  http://smalltalkhub.com/#!/~TorstenBergmann/WebDriver

This implements the JsonWireProtocol so it is not necessary to install Java/Selenium and is
(hopefully) a cleaner implementation together with tests. Pharo only.

Simple How to:
==============
 - The project is currently written and working for Windows platform (but will be
   platform independent later)

 - run

     Metacello new
         configuration: 'WebDriver';
         smalltalkhubUser: 'TorstenBergmann' project: 'WebDriver';
         load.

   to load the project and all dependencies

 - Download ChromeDriver.exe and put it into the image directory
   https://chromedriver.storage.googleapis.com/index.html?path=2.30/

   You can also set a different location in "WebDriver" -> "Settings"

 - in the World menu choose "WebDriver" -> "ChromeDriver" -> "Run Chrome Driver"

 - open a playground and run

     wd := WDWebDriver new.
     wd url: 'http://www.pharo.org'.
     wd screenshotForm inspect

  which should open a chrome window.

It's not yet finished but if you like you can help completing it.

Bye
T.