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

192
Visualizações
driver.switchTo.frame is not a function

I am new to Selenium. Here is the task:

  1. Open https://pastebin.com
  2. Paste "Hello from WebDriver"
  3. Set past expiration to 10 Minutes //I am having problems here
  4. Set paste title as "helloweb"

I am using javascript, with chromedriver

I am able to open the dropdown but cant choose the expiration time, it says:

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>

So i found out that the choices are hidden inside a frame(i am new to this). I used driver.switchTo.frame(driver.findElement(xpath)) function

Here is my code:

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();
  }
})();

But it says "driver.switchTo.frame is not a function". How can i fix this? Please help

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

0

Remove .click() from switch to frame line code.

await driver.switchTo.frame(driver.findElement(By.xpath('//*[@id="postform-expiration"]/option[3]')));
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