I am currently working on a piece of code and have done many readings using the documentary and looked at many examples, but still I cannot fix my bug. I am using Python and Selenium Webdriver.
Here's the problem: I am trying to extract an image from an HTML page that uses Javascript. The results from the function call are displayed (in firefox) once I use the selenium webdriver, but I cannot click on a number at the bottom of the page to go onto the 3rd or 4th page.
Here is the HTML code that I am having issues with:
<div class="pagebook" data-reactid=".1.0.2.0"><div style="display:none;" data-reactid=".1.0.2.0.0"></div><div class="active" data-reactid=".1.0.2.0.1:$0">1</div><div class="" data-reactid=".1.0.2.0.1:$1">2</div><div class="" data-reactid=".1.0.2.0.1:$2">3</div><div class="" data-reactid=".1.0.2.0.1:$3">4</div><div class="" data-reactid=".1.0.2.0.1:$4">5</div><div class="" dat<div class="next" style="margin-right:20px;" data-reactid=".1.0.2.0.$6">►</div></div>
I did this call using xpath capability: browser.find_element_by_xpath('//div[@data-reactid=".1.0.2.0.1:$2"]').click()
The first time I did this it worked a few times and then it gave me an error and I could never use it again. The error was:
File "C:\Python27\Lib\site-packages\selenium-2.49.2-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 111, in check_response
message = value["value"]["message"]
TypeError: string indices must be integers
Here is the code that I am using:
browser = webdriver.Firefox()
browser.implicitly_wait(5) #backup wait of 5 seconds just in case
browser.get(url2)
browser.find_element_by_xpath('//div[@data-reactid=".1.0.2.0.1:$2"]').click()
What I am looking for help with:
- The error
- Using a different function for clicking
Appreciate it!