Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

374
Visualizações
Haga clic en la página del titiritero usando el selector de atributos con espacios

Este código Meteor usa Titiritero 13.1.2 en el servidor. Utiliza un bucle for para abrir a enlace usando su atributo de título. Funciona siempre que el valor no tenga espacios, pero no abre la página emergente con los valores de atributo que contienen espacios. ¿Alguna idea de cómo abrir estas ventanas emergentes? Gracias

 const headings = ['One', 'Tow', 'Three/Four', 'Five Six', "Seven and more"] for (let i = 0; i < headings.length; i++) { console.log('headings: ', headings[i]) const [popup] = await Promise.all([ new Promise((resolve) => page.once('popup', resolve)), page.click('a[title~="' + headings[i] + '"]'), ]); }
 <tr class="rowDark"> <td width="10%" align="center"> <input type="checkbox" name="selectedCheckboxes" value="Five Six" disabled="disabled" id="FiveSix" /> </td> <td width="90%" class="smallText" align="left"> <a href="/is/ASD.do?action=create&area=Five Six&iType=e" class="textLink" target="sons" title="Five Six (opens new window)" onclick="return displayReason(this.href);"> Five Six </a> </td> </tr>

Con el código anterior recibí el siguiente error: Error: No node found for selector: a[title~="Five Six"]

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Primero puede seleccionar todos los elementos .textLink y luego filtrar los elementos encontrados por el texto de su valor de título. Aquí hay 2 funciones auxiliares para filtrar elementos por sus propiedades:

 // allows selecting a property from an elementhandle like title OR text or something, async function getPropertyValue(element, property) { const textElement = await element.getProperty(property) const text = await textElement.jsonValue() return text.trim() } // filters an array of elementHandles against some property. // Ideal for filtering elements by its title value for example. async function filterByPropertyValiue(elements, property, searchValue) { for(let element of elements) { // you can apply some transformations to value OR searchValue // in order to remove some stuff or make the matching appropriate to your // use case. const value = await getPropertyValue(element, property) if(value === searchValue) { // when found return element return element } } // if not found throw. throw 'Element not found by propertyValue. property: ' + property + ', value: ' + searchValue }

En su ejemplo particular, esto ahora debería funcionar:

 const openPopup = async (page, titleText, timeoutMs) => { // return whole promise so timeout can be applied. const links = await page.$$('a.textLink') // throws if target is not found. const target = await filterByPropertyValiue(links, 'title', titleText) const popup = new Promise((resolve, reject) => { page.once('popup', resolve) // it is nice to have a timeout on this. setTimeout(reject, timeoutMs) }) // run the click not directly for letting the above // promise work first. process.nextTick(() => { page.click(target) }) return popup } // ope the popups.. const headings = ['One', 'Tow', 'Three/Four', 'Five Six', "Seven and more"] // select links in advance.. for (let i = 0; i < headings.length; i++) { console.log('headings: ', headings[i]) const popup = await openPopup(page, headings[i], 15 * 1000) }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda