Vauxoo / odoo-selenium

Odoo Selenium Unittest Tools provides utilities that make it easy to quickly write and develop Odoo tests that use Selenium.
GNU Lesser General Public License v3.0
1 stars 2 forks source link

Added new file for common expectations #5

Closed antonag32 closed 1 year ago

antonag32 commented 1 year ago

Most test cases will need to use explicit waits to assert certain conditions have happened before proceeding. A new file which implements common conditions needed throughout tests has been added.

A new method navigate which uses one of these expectations has also been added. This ensures Odoo's frontend has loaded completely before proceeding, preventing stuff like clicks not being registered from happening.

antonag32 commented 1 year ago

Marked as draft, needs #4 to be merged first.

antonag32 commented 1 year ago

Also owl.config no longer exists, so the condition to wait for OWL needs to change. Accessing the app list through __OWL_DEVTOOLS__ to get their state seems like a promising new method.

antonag32 commented 1 year ago

Found the following workaround for Odoo 16:

return Array.from(__OWL_DEVTOOLS__.apps).some((app) => app.root?.status === 1)

Tested on Runbot 16.0 and master. If you set a breakpoint during bootstrap, __OWL_DEVTOOLS__ is not defined, and status === 1 means the app has been mounted, so it seems safe enough to think OWL has finished loading by then.

Can you review @moylop260 @luisg123v ?

moylop260 commented 1 year ago

@antonag32

I'm checking odoo httpcase class and I found the following validation:

Could you check if it is compatible with Selenium, please?

antonag32 commented 1 year ago

@antonag32

I'm checking odoo httpcase class and I found the following validation:

Could you check if it is compatible with Selenium, please?

If I remember correctly that was one of the methods initially tried when selenium tests were first written. I tried it once more with IRC's current test suite and most of the time they don't work.

My understanding is that document.readyState just states whether all files have been downloaded or not. However after downloading, Odoo's OWL framework still needs to bootstrap itself and mount the main Application component onto the DOM.

The new method proposed checks if the component has been mounted, as you can see:

https://github.com/odoo/odoo/blob/01f5e74293fd6d1e00762ca084d4a6ce36fdc8c2/addons/web/static/lib/owl/owl.js#L5812-L5821

Status 1 means it has been mounted which makes it safer to assume it is ready to be interacted with IMHO.