Issue
I tried everything but I couldn't switch the selenium to the iframe. If you click here and then click on the first name (Maria José Panichi Vieira) and then click on (contato) a frame will open. Could anyone go to the link and give me an idea of how I can switch to it?
Solution
wait=WebDriverWait(driver, 60)
url = "http://buscatextual.cnpq.br/buscatextual/busca.do?metodo=forwardPaginaResultados®istros=0;10&query=(%2Bidx_nme_pessoa:(a)%20%20%2Bidx_particao:1%20%2Bidx_nacionalidade:e)%20or%20(%2Bidx_nme_pessoa:(a)%20%20%2Bidx_particao:1%20%2Bidx_nacionalidade:b%20%5E500%20)&analise=cv&tipoOrdenacao=null&paginaOrigem=index.do&mostrarScore=false&mostrarBandeira=true&modoIndAdhoc=null"
driver.get(url)
wait.until(EC.element_to_be_clickable((By.XPATH,"//div[@class='resultado']//ol/li[1]/b/a"))).click()
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#idbtncontato"))).click()
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"(//div[@class='layout-modalcell conteudo']/iframe)[2]")))
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#nomeRemetente"))).send_keys("stuff")
Switch to that iframe using frame_to_be_available using Webdriver waits and send stuff to it's input tag.
<iframe width="100%" height="500px" frameborder="0" scrolling="no" allowtransparency="true" src="/buscatextual/email.do?metodo=apresentar&seqIdPessoa=246740&nomeDestinatario=Maria_José_Panichi_Vieira" cd_frame_id_="e5a878454b90d180bbc777ce26477cd5"></iframe>
Imports:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Answered By - Arundeep Chohan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.