Estoy atascado en esto y espero que me puedas señalar en la dirección correcta.
Estoy usando una nueva herramienta de monitoreo de reliquias y necesito crear una prueba de monitoreo del viaje típico del usuario de comercio electrónico, buscar, seleccionar un producto, seleccionar un tamaño y luego agregarlo a la bolsa.
El problema que tengo es que algunos tamaños de productos se agotan y eso rompe mi prueba. Tengo el siguiente código que me permite elegir un producto específico, pero ¿alguien sabe cómo seleccionar la primera opción disponible?
Cualquier ayuda sería apreciada.
Gracias
//Example: Selecting an option and retrieving the selected label/value var By = $driver.By, selectbox; // ----------------------------------------------------------------------------- // // Helper function that returns the first selected option given a select element function findSelected(select) { var d = $driver.promise.defer(); select.findElements(By.tagName('option')).then(function (options) { options.forEach(function(option) { option.isSelected().then(function(selected) { if (selected) { d.fulfill(option); } }); }); }); return d.promise; } // ----------------------------------------------------------------------------- // // Load the page $browser.get("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_select2").then(function(){ // Focus the iframe $browser.switchTo().frame("iframeResult"); // Click on select return $browser.waitForAndFindElement(By.name("cars"), 15000).then(function(elem) { selectbox = elem; selectbox.click(); }); }).then(function() { // Select an option return selectbox.findElement(By.css("option[value='audi']")).click(); })