Soy nuevo en Selenium. Aquí está la tarea:
estoy usando javascript, con chromedriver
Puedo abrir el menú desplegable pero no puedo elegir el tiempo de vencimiento, dice:
ElementClickInterceptedError: element click intercepted: Element <span class="select2-selection__arrow" role="presentation">...</span> is not clickable at point (422, 569). Other element would receive the click: <iframe frameborder="0" src="https://9c4fe1b6ba8be5733ce3e7442f84515f.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html" id="google_adsiframe/22653346938/12825_Pastebin.com/12825_Pastebin.com_SmartBanner_1_0" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="970" height="90" data-is-safeframe="true" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" role="region" aria-label="Advertisement" tabindex="0" data-google-container-id="1" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe>Entonces descubrí que las opciones están ocultas dentro de un marco (soy nuevo en esto). Usé la función driver.switchTo.frame(driver.findElement(xpath))
Aquí está mi código:
const { Browser } = require('selenium-webdriver'); const {Builder, By, Key, until} = require('selenium-webdriver'); const { waitForServer } = require('selenium-webdriver/http/util'); (async function example() { let driver = await new Builder().forBrowser('chrome').build(); driver.manage().window().maximize(); try { await driver.get('https://pastebin.com'); await driver.findElement(By.xpath('//*[@id="postform-text"]')).sendKeys('Hello from WebDriver'); await driver.findElement(By.xpath('//*[@id="w0"]/div[5]/div[1]/div[2]/div/span/span[1]/span/span[2]')).click() await driver.switchTo.frame(driver.findElement(By.xpath('//*[@id="postform-expiration"]/option[3]'))).click() await driver.findElement(By.xpath('//*[@id="postform-name"]')).sendKeys('helloweb'); await driver.findElement(By.xpath('//*[@id="w0"]/div[5]/div[1]/div[8]/button')).click(); } finally { await driver.quit(); } })();Pero dice "driver.switchTo.frame no es una función". ¿Cómo puedo arreglar esto? Por favor ayuda
Elimine .click() del código de cambio a línea de cuadro.
await driver.switchTo.frame(driver.findElement(By.xpath('//*[@id="postform-expiration"]/option[3]')));