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

200
Visualizações
¿Cómo verificar cuándo el JS ha cambiado HTML en la respuesta de AJAX?

Intentamos raspar un sitio web usando Selenium, JAVA, por ejemplo. intente cambiar el color del producto en https://www.ergodyne.com/shax-6054-pop-up-tent-sidewall-kit-includes-10ftx10ft
¿Cómo averiguar/comprobar cuándo el JS en el sitio ha cambiado el HTML a la llegada de la respuesta AJAX?
¿Qué tan grande debería ser el retraso después de la respuesta AJAX/XHR y JS reemplazó HTML? Las consultas de AJAZ son bastante complicadas para tratar de obtener datos de ellas...

Enlace para la respuesta JSON: https://jsonformatter.org/298d31

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

0

Usando org.openqa.selenium.support.ui.ExpectedConditions y org.openqa.selenium.support.ui.WebDriverWait . Consulte https://www.guru99.com/implicit-explicit-waits-selenium.html

Código:

 package tests; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class IgorSavinking { public static String userDir = System.getProperty("user.dir"); public static String chromedriverPath = userDir + "\\resources\\chromedriver.exe"; public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", chromedriverPath); ChromeOptions options = new ChromeOptions(); options.addArguments("--ignore-certificate-errors"); options.addArguments("--start-maximized"); options.addArguments("--disable-notifications"); WebDriver driver = new ChromeDriver(options); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get("https://www.ergodyne.com/shax-6054-pop-up-tent-sidewall-kit-includes-10ftx10ft"); driver.findElement(By.id("cookie-policy-accept")).click(); String colorBefore = driver.findElement(By.tagName("legend")).getText().substring(5); System.out.println("Current color is: " + colorBefore); driver.findElement(By.xpath("//label[contains(@for,'edit-purchased-entity-0-attributes-attribute-color-17')]")).click(); new WebDriverWait(driver, 30).until(ExpectedConditions.numberOfElementsToBe(By.xpath("div[@class='message']"), 0)); String colorAfter = driver.findElement(By.tagName("legend")).getText().substring(5); System.out.println("Current color is: " + colorAfter); System.out.println("Color has been changed: " + !colorBefore.equals(colorAfter)); driver.quit(); } }

Producción:

 Starting ChromeDriver 97.0.4692.71 (adefa7837d02a07a604c1e6eff0b3a09422ab88d-refs/branch-heads/4692@{#1247}) on port 38237 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Úno 02, 2022 8:02:15 DOP. org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Current color is: Lime Current color is: Blue Color has been changed: true
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