What is Automated Test ??
- Automated Test is known as Tour.
- Tour means sequence of steps.
- In odoo we use this thing in two different way
- Tutorial
- Each step wait for user to do something ,before moving next step
- Used to guide user with tutorial.
- Test
- Same as tutorial but in this js code simulate an user
- Used to test front-end addons ui process automatically.
- Tutorial
- Tour is defined by "openerp.Tour.register" with following attributes
- id : We can give any name for unique ideffication used to run the tour
- name : Display the name in help menu.
- path : Path to redirect on specific page when tour get start
- mode : Test or Tutorial
- steps :
- This contain sequeance of steps.
- It is defined with selection attributes like below
- We can use as per requirement not all.
- title : It indicate title of tip
- content : Message of the tip
- element : element on which we want to point the tip
- placement : placement of tip [left,right,bottom,top] according to element
- waitFor : wait for run step until condition not satisfy
- waitNot : wait not to run step if condition satify
- popover : we can set three option
- next : indicate button with text , when click on it execute next step
- end : same as above but it stop the tour
- fixed : true [used to set fixed position of tour]
- sampleText : supply the text input/select when it used in test mode
- suupose we want simple tour for website with the following steps
- Welcome step
- Show edit button to user so user can edit it.
- Now show the tip to drag and drop snippet.
- After that show save button tip to save all thing.
- Last tip about thanks.
- Refer the following code we have to put that code in one separate JS file and put it in frontend asset bundle.
openerp.Tour.register({
id: 'tourdemo',
name: _t("Demo Tour"),
path: '/page/homepage',
steps: [
{
title: _t("Welcome to your website!"),
content: _t("This tutorial will guide you to build your home page. We will start by adding a banner."),
popover: { next: _t("Start Tutorial"), end: _t("Skip It") },
},
{
element: 'button[data-action=edit]',
placement: 'bottom',
title: _t("Edit this page"),
content: _t("Every page of your website can be modified through the <i>Edit</i> button."),
popover: { fixed: true },
},
{
snippet: '#snippet_structure .oe_snippet:first',
placement: 'bottom',
title: _t("Drag & Drop a Banner"),
content: _t("Drag the Banner block and drop it in your page."),
popover: { fixed: true },
},
{
element: 'button[data-action=save]',
placement: 'right',
title: _t("Save your modifications"),
content: _t("Publish your page by clicking on the <em>'Save'</em> button."),
popover: { fixed: true },
},
{
waitFor: 'button[data-action=save]:not(:visible)',
title: _t("Good Job!"),
content: _t("Well done, you created your homepage."),
popover: { next: _t("Continue") },
},
]
});
- Tutorial
- When you add this JS in asset frontend its link to start automatically added in help menu in odoo website.
- To check manually you can user following
- In console type : openerp.Tour.run('id of tour')
- You can pass mode as well like : openerp.Tour.run('id of tour','test')
- Test
class TestUi(openerp.tests.HttpCase):
def test_02_admin_tour_demo(self):
self.phantom_js("/", "openerp.Tour.run('tourdemo', 'test')", "openerp.Tour.tours.tourdemo", login='admin')
Note - Element selection should be accurate otherwise it create problem , if same type of two element .
- Same like this waitNot and waitFor should be accurate
- If you want to perform some action on load of step then you can add it like below
{
title: _t("Welcome to your website!"),
content: _t("This tutorial will guide you to build your home page. We will start by adding a banner."),
popover: { next: _t("Start Tutorial"), end: _t("Skip It") },
onload : function(){
//do something
},
},
Comments
Post a Comment