daniboy000
daniboy000

Reputation: 1129

Fire event with python selenium

I have a button bar on a web page that allows me to navigate to a specific page if I click on the page button. I need to know if it's possible with python selenium to fire a event for a specific page. For instance, if I want to go directly to page '100', how can I fire this event with python selenium. Follows below examples of the page buttons.

<td class="rich-datascr-inact " onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': '1'});">1</td>
<td class="rich-datascr-inact " onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': '2'});">2</td>
<td class="rich-datascr-inact " onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': '3'});">3</td>

Upvotes: 1

Views: 2451

Answers (1)

cieunteung
cieunteung

Reputation: 1791

you can try execute the code with execute_script()

# find element for argument "this"
thisEl = driver.find_element_by_xpath('//td[contains(@class, "rich-datascr-inact") and contains(text(), "100")]')
driver.execute_script('''
window.Event.fire(arguments[0], 'rich:datascroller:onscroll', {'page': '100'})
''', thisEl)

Upvotes: 3

Related Questions