Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

Iam tested webscraping the page:http://www.guiadosquadrinhos.com/todas-capas-disponiveis

I need navigate in pagination geting info pages favorite. I need click link javascript next page:

javascript:__doPostBack('ctl00$MainContent$lstProfileView$dataPagerNumeric2$ctl02$ctl00')

from selenium import webdriver
import time

driver = webdriver.PhantomJS(executable_path='C:\Python27\Tools\phantomjs\phantomjs.exe')
driver.get("http://www.guiadosquadrinhos.com/todas-capas-disponiveis")
#print(driver.find_elements_by_class_name("numero_capinha")[0].text)
#driver.find_elements_by_class_name("next_last")[0].click()
#time.sleep(5)
print(driver.find_elements_by_class_name("numero_capinha")[0].text)
driver.find_elements_by_class_name("next_last")[0].click()
print(driver.find_elements_by_class_name("numero_capinha")[0].text)

My code return:

sobreontem - Independente

Traceback (most recent call last): File "teste_selenium.py", line 10, in driver.find_elements_by_class_name("next_last")[0].click() File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 74, in click self._execute(Command.CLICK_ELEMENT) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py", line 453, in _execute return self._parent.execute(command, params) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementNotVisibleException: Message: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"81","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:63160","User-Agent":"Python-urllib/2.7"},"httpVersion":"1.1","method":"POST","post":"{\"sessionId\": \"5d3cfdc0-5d3b-11e5-b784-67706273a0bb\", \"id\": \":wdc:1442494581220\"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/5d3cfdc0-5d3b-11e5-b784-67706273a0bb/element/%3Awdc%3A1442494581220/click"}} Screenshot: available via screen

Whats is problem ?

share|improve this question
    
Please post the html of the relevant next_last element. It seems it is not currently visible on the text page and you will have to execute some javascript to bring it to visibility. – Vikas Neha Ojha Sep 17 at 13:06
    
<a class="next_last" href="javascript:__doPostBack('ctl00$MainContent$lstProfileView$dataPagerNumeric2‌​$ctl02$ctl00','')">&gt;</a> – Victor Sued Sep 17 at 13:08

1 Answer 1

up vote 1 down vote accepted

Since, you are doing the following -

driver.find_elements_by_class_name("next_last")[0].click()

If you look in the source, there are multiple elements with this class name and the first one is disabled, because that is for the previous button and you are on first page.

share|improve this answer
    
Is true! Thanks, resolved my problem, Solved this code: driver.find_elements_by_class_name("next_last")[2].click() – Victor Sued Sep 17 at 13:23
    
@VictorSued see stackoverflow.com/help/someone-answers. – alecxe Sep 17 at 13:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.