I can not find an element by Id

0

I'm automating an operation on a site with the Selenium Webdriver and in a certain region of the site when I send a wait using WebDriverWait it exceeds the maximum time and does not think so, but I checked several times the Id and is correct, this problem had already happened in other regions of the site, but I was able to solve by giving driver.SwitchTo().Frame("NomeDoIframe") , ie changing to the iframe where the elements were, but now when I do this it gives error saying that it can not find the iframe . I am using the PhantomJS browser.

    
asked by anonymous 23.09.2015 / 19:06

2 answers

0

To switch to the Frame with an Id, you need to pass the command as follows:

driver.SwitchTo().Frame(driver.FindElement(By.Id("Id_Do_Seu_Iframe")));
    
26.07.2017 / 16:41
0

After evaluating the rendered page, make a document.getElementById:

 var page = require('webpage').create();
 page.open('http://www.meusite.org', function(status) {
   if (status !== 'success') {
     console.log('Sem conexão');
   } else {
     var ua = page.evaluate(function() {
       return document.getElementById('idBotao').textContent;
     });
     console.log(ua);
   }
   phantom.exit();
 });

If you want to use the Jquery selector do a lib include before:

page.includeJs(pathJquery, function() 
{
     var res = page.evaluate(function () 
     {
        $('#obj').text();
     }
}

link

    
29.12.2016 / 15:21