The Artima Developer Community
Sponsored Link

Java Buzz Forum
Testing Mendix applications using Selenium

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andrej Koelewijn

Posts: 594
Nickname: andrejk
Registered: Nov, 2002

Andrej Koelewijn is a Java and Oracle consultant
Testing Mendix applications using Selenium Posted: Oct 5, 2013 2:43 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Andrej Koelewijn.
Original Post: Testing Mendix applications using Selenium
Feed Title: Andrej Koelewijn
Feed URL: http://feeds.feedburner.com/AndrejKoelewijn
Feed Description: On Oracle, Java and OpenSource
Latest Java Buzz Posts
Latest Java Buzz Posts by Andrej Koelewijn
Latest Posts From Andrej Koelewijn

Advertisement

Selenium is a useful tool for automating functional tests. In this post i’ll show you some tips and tricks about using Selenium IDE with Mendix. Selenium IDE is a Firefox plugin that enables you to record whatever you are doing in Firefox, so that you can repeat these steps as a test script.

Selenium IDE

You can use Selenium IDE to record tests scripts, but these scripts need to be edited before you can use them:

  • Replace id targets with xpath targets

    • Most buttons you can target by the text in the button

      mouseDown //button[text()='New']
      
    • You can target input fields by the label before it:

      type //input[ancestor::tr/th/label='Omschrijving'] test-value
      

      This xpath expression selects the input element, which is in a table row, that has a table header containing a label Omschrijving.

    • If you have a form with multiple columns, you can use the following xpath:

      type //input[preceding::th[1]/label='Omschrijving'] test-value 
      

      This xpath expression tells Selenium to select the input field where the closest preceding table header contains a label Omschrijving.

    • To choose a value from a dropdown list:

      select //select[preceding::th/label='Af Bij'] label=Af
      

      This selects the value Af from a dropdown list preceded bij a label Af Bij.

    • To edit an entity from a DataGrid table, you can use the following:

      waitForElementPresent //table//tr/td/div[text()='test-transactie-1']
      doubleClick //table//tr/td/div[text()='test-transactie-1']
      

      This will cause a double click on a tablecell containing the text test-transactie-1.

  • Replace most mouse clicks with mouseDown mouseUp. To click on a button you need the following commands:

    mouseDown //label[text()='Save']
    mouseUp //label[text()='Save']
    

    Btw, you don’t need to do this for popup alter windows. Here you can use click:

    click //button[text()='OK'] 
    
  • Add a fireEvent blur after typing text in an input field:

    fireEvent //input[preceding::th[1]/label='Btw percentage'] blur
    
  • Add waitForElementPresent commands, for example:

    waitForElementPresent //button[text='New']
    waitForElementPresent //h1[text()='Boek']
    
  • An ofcourse, a test script wouldn’t be complete without some actual tests:

    verifyValue //input[preceding::th[1]/label='Bon nummer'] 123
    

    This verifies that the page contains an input field preceded by a label Bon nummer contains the value 123.

    assertVisible //table//tr/td/div[text()='inkoop-1-checked']
    

    This checks a table cell contains the value inkoop-1-checked.

    assertVisible //h1[text()='Edit Boek']
    

    This verifies that the page contains a header with the text Edit Boek.

    assertVisible //div[@class='alert alert-error'][text()='Invalid currency']
    

    This verifies that the page contains an error message with the text Invalid currency.

    assertElementNotPresent //dev[@class='alert alert-error']
    

    This verifies that the page doesn’t contain any error messages.

This has been tested with Mendix 5.0.0 beta 7. You’ll probably need different xpath expressions for other versions of Mendix. Firefox inspector is a useful tool for inspecting the generated html to determine the correct xpath expressions.

Read: Testing Mendix applications using Selenium

Topic: Google account Integration in Android – Login with Gmail Previous Topic   Next Topic Topic: IntelliJ IDEA 12.1.5 Update is Available

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use