TT#56376 selenium: use CTRL+A shortcut in fill_element() instead of clear()

clear() would trigger a search in the table, which could lead in some cases
to "stale_element_reference" errors. CTRL+A doesnt do this and allows to
make search requests, especially those with only one existing element in
the table to be much simpler.

Change-Id: I8e107f8adf45fae95304482176f3f67d9e28bca6
changes/71/29371/1
Nico Schedel 7 years ago
parent d6a901d97b
commit 628f26bd96

@ -60,7 +60,7 @@ sub create_reseller {
diag('Try to create a reseller');
$self->driver->find_element('Create Reseller', 'link_text')->click();
$self->driver->fill_element('//*[@id="contractidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#contractidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
ok($self->driver->find_element_by_css('#contractidtable tr > td.dataTables_empty'), 'Garbage text was not found');
$self->driver->fill_element('//*[@id="contractidtable_filter"]/label/input', 'xpath', $resellerid);
ok($self->driver->wait_for_text('//*[@id="contractidtable"]/tbody/tr/td[3]', $resellerid), "Default Contact found");
$self->driver->select_if_unselected('//*[@id="contractidtable"]/tbody/tr/td[5]/input');
@ -78,13 +78,11 @@ sub create_reseller_contract {
diag('Try to create a reseller contract');
$self->driver->find_element('Create Reseller Contract', 'link_text')->click();
if(!$self->driver->find_element('//*[@id="contactidtable"]/tbody/tr[1]/td[4]')->get_text() eq 'default-system@default.invalid') {
$self->driver->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'default-system@default.invalid');
ok($self->driver->wait_for_text('//*[@id="contactidtable"]/tbody/tr[1]/td[4]', 'default-system@default.invalid'), "Default Contact found");
$self->driver->select_if_unselected('//*[@id="contactidtable"]/tbody/tr[1]/td[5]/input');
} else {
ok($self->driver->select_if_unselected('//*[@id="contactidtable"]/tbody/tr[1]/td[5]/input'), "Default Contact found");
};
$self->driver->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#contactidtable tr > td.dataTables_empty'), 'Garbage text was not found');
$self->driver->fill_element('//*[@id="contactidtable_filter"]/label/input', 'xpath', 'default-system@default.invalid');
ok($self->driver->wait_for_text('//*[@id="contactidtable"]/tbody/tr[1]/td[4]', 'default-system@default.invalid'), "Default Contact found");
$self->driver->select_if_unselected('//*[@id="contactidtable"]/tbody/tr[1]/td[5]/input');
$self->driver->scroll_to_element($self->driver->find_element('//*[@id="external_id"]'));
$self->driver->fill_element('//*[@id="billing_profileidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');

@ -4,7 +4,7 @@ use warnings;
use strict;
use TryCatch;
use Moo;
use Selenium::Remote::WDKeys;
use Test::More import => [qw(diag ok is)];
extends 'Selenium::Firefox';
@ -81,7 +81,7 @@ sub fill_element {
my $elem = $self->find_element($query, $scheme);
return 0 unless $elem;
return 0 unless $elem->is_displayed;
$elem->clear();
$elem->send_keys(KEYS->{'control'}, 'A');
$elem->send_keys($filltext);
return 1;
}

Loading…
Cancel
Save