Skip to content

Commit

Permalink
improve wait time when selecting dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Sep 22, 2023
1 parent 01552c3 commit 92a2981
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions tests/UI/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/

exports.sendFieldValue = async function (page, selector, text)
{
await page.evaluate((selector) => {
$(selector).val('').change();
}, selector);
exports.sendFieldValue = async function (page, selector, text) {
await page.evaluate((selector) => {
$(selector).val('').change();
}, selector);

await page.waitForFunction("$('" + selector + "').val() == ''");
// page.sendKeys(selector, text);
await page.waitForFunction(() => $(selector).val() === '');

await page.evaluate((selector, text) => {
$(selector).val(text).change();
}, selector, text);
await page.evaluate((selector, text) => {
$(selector).val(text).change();
}, selector, text);

await page.waitForFunction("$('" + selector + "').val() != ''");
await page.waitForFunction(() => $(selector).val() === text);
};
exports.selectValue = async function (page, field, title)
{
await page.evaluate((field) => {
$(field + ' input.select-dropdown').click()
}, field);
await page.waitForTimeout(800);
await page.evaluate((field, title) => {
$(field + ' .dropdown-content li:contains("' + title + '"):first').click()
}, field, title);
exports.selectValue = async function (page, field, title) {
await page.evaluate((field) => {
$(field + ' input.select-dropdown').click()
}, field);

await page.waitForFunction(() => $(field + ' .dropdown-content li:contains("' + title + '")').length() > 0);

await page.evaluate((field, title) => {
$(field + ' .dropdown-content li:contains("' + title + '"):first').click()
}, field, title);
};

0 comments on commit 92a2981

Please sign in to comment.