Reputation: 1
I've been working on a custom Odoo12 tour test, and I’m running into an issue with selecting items from a dynamically-generated dropdown. Here’s a breakdown of the steps I'm trying to implement:
The problem comes with the Step 3: the dropdown items seem to have dynamically changing IDs (e.g., #o_field_input_170, #o_field_input_167, etc.), so I can’t target a specific ID.
Here’s what I’ve tried to solve it:
Here's the code example with the Key event:
tour.register('test2_tour', {
test: true,
url: "/web",
wait_for: base.ready(),
}, [
// previous steps...
{
content: "Click on Add a product",
trigger: 'a:contains("Add a product")',
},
{
content: "Set product code",
trigger: '#o_field_input_875',
run: 'text 167020',
},
{
content: "Select the product",
trigger: '#o_field_input_875',
run: 'keydown 13',
},
{
content: "Confirm the product",
trigger: '.modal-footer > .btn:nth-child(1) > span',
},
]);
The CSS selector of the dropdown is the following:
.o_form_nosheet > div:nth-child(3) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2) > div:nth-child(1) > div:nth-child(1)
Has anyone faced a similar issue, or does anyone have a reliable approach to wait for and select a dynamically generated dropdown item in an Odoo tour test?
There's not much documentation, specially for Odoo12 for this topic, so any extra documentation that may be usefu
Thanks in advance for any help!
Upvotes: 0
Views: 40
Reputation: 1314
It seems that there is not problem with this kind of css selector because it is used in official addons too (addons website_slides > slides_tour.js):
{
trigger: 'iframe li.breadcrumb-item:nth-child(2)',
content: Markup(_t("Click on your <b>Course</b> to go back to the table of content.")),
position: 'top',
}
How about using div name=product_id to select the parent of your nth-child?
Is the problem maybe due to the fact that the modal content does not exist yet when performing your test ?
For instance, in skils_tour.js:
{
content: "Save it",
trigger: ".o_form_button_save",
in_modal: true,
run: "click",
},
Upvotes: 0