Issue
I'm automating a page using selenium. There is a text on a page "Show More Matches" with OnClick function at the backend. It shows 5 more matches by default when I click on it. You can see in below code that argument is set to 5. I want to get 20 more matches by clicking on the text. Right Now I'm doing it manually by editing the HTML and replacing it with 20. I want to do it using Selenium
<td colspan="6" class="last lastR">
<a class="show_more"
onclick="glib_show_hidden('','h2h_home',5); return false"
href="#">
Show more matches <span class="arrow"></span>
</a>
</td>
Solution
You can change the attribute of this element:
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement element = driver.findElement(element_locator);
js.executeScript("arguments[0].setAttribute('data-ved', 'glib_show_hidden(\\'\\',\\'h2h_home\\',20); return false');",element);
for python:
element = driver.find_element_by_xpath("your_xpath")
driver.execute_script("arguments[0].setAttribute('data-ved', 'glib_show_hidden(\\'\\',\\'h2h_home\\',20); return false');",element);
Answered By - Norayr Sargsyan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.