Cómo seleccionar un solo elemento en transportador
Normalmente en protractor puedes seleccionar el elemento singular con:
element(protractor.By.css('#fdfdf'));
De vez en cuando se obtiene algo como esto:
element(protractor.By.css('.dfdf'));
Que potencialmente tiene más de un elemento. ¿Cuál es la forma correcta de seleccionar un índice de un localizador que localiza múltiples elementos y aún contiene los métodos del transportador para enviar Claves?
36
Author: Mark Baker, 2013-11-27
3 answers
Puede obtener un elemento indexado de un array devuelto con
// Get the 5th element matching the .dfdf css selector
element.all(by.css('.dfdf')).get(4).sendKeys('foo');
71
Author: Jmr,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-04 22:51:28
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-04 22:51:28
Si desea obtener el primer elemento,
element.all(by.css('.dfdf')).first();
element.all(by.css('.dfdf')).get(0);
14
Author: Zaman Afzal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-22 21:12:39
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-22 21:12:39
Prueba este. Funcionará:
element.all(by.css('.dfdf')).get(4).getText();
2
Author: ARB,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-19 21:35:19
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-19 21:35:19