JavaScript Python Selenium: Click a href=“javascript:()” python selenium click button,python selenium click element,python selenium

I am using chromedriver and I have the following webpage source:

<form id="stepLinksForm" name="stepLinksForm" method="POST" target="mainFrame"> 

  <ul> 
      <li> <a target='_blank' href="javascript:submitLink('action_one.htm')">Action One</a> </li>
      <li> <a target='_blank' href="javascript:submitLink('action_two.htm')">Action Two</a> </li>
      <li> <a target='_blank' href="javascript:submitLink('action_three.htm')">Action Three</a> </li>
  </ul>   

</form>

After clicking anyone of the href, the browser goes to a new page but the url stays the same. What I want to achieve is clicking the first href, i.e. <li> <a target='_blank' href="javascript:submitLink('action_one.htm')">Action One</a> </li>

I have tried find_element_by_xpath, link_text and some other methods suggested on the Internet but none of them works. I really appreciate if someone could help.

Answer:1

Instead of click you can call the javascript code directly:

browser.execute_script("submitLink('action_one.htm')")

which equivalent to javascript:submitLink('action_one.htm')

Or you can find the a by its text:

browser.find_elements_by_xpath("//a[contains(text(), 'Action One')]")
Answer:2

I have a transition set: element.one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ scrollActive = false; }).css({ '-webkit-transform': '' + prop + '(' + ...

I have a transition set: element.one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ scrollActive = false; }).css({ '-webkit-transform': '' + prop + '(' + ...

I'm trying to convert svg to canvas using the canvg js lib. The original svg contains a rect which has a fill attribute of url to a svg pattern. When I convert the svg to canvas using canvg: canvg(...

I'm trying to convert svg to canvas using the canvg js lib. The original svg contains a rect which has a fill attribute of url to a svg pattern. When I convert the svg to canvas using canvg: canvg(...

So I have a user view and an admin view that are very similar except that an admin view can upload new data to my web app which displays different charts; thus I want to use the same controller that ...

So I have a user view and an admin view that are very similar except that an admin view can upload new data to my web app which displays different charts; thus I want to use the same controller that ...

  1. pass variable from php to javascript
  2. pass variable from html to javascript
  3. pass variable from batch to powershell
  4. pass variable from child to parent react
  5. pass variable from process builder to flow
  6. pass variable from bash to python
  7. pass variable from userform to module vba
  8. pass variable from child to parent angular
  9. pass variable from javascript to flask
  10. pass variable from python to javascript
  11. pass variable from html to php
  12. pass variable from js to html
  13. pass variable from python to html
  14. pass variable from powerapps to flow
  15. pass variable from django to javascript
  16. pass variable from try to catch
  17. pass variable from php to jquery
  18. pass variable from playbook to role ansible
  19. pass variable from cmd to powershell
  20. pass variable from pug to javascript

I need to make a video page for my website which must contain a video from youtube (https://www.youtube.com/watch?v=bWPMSSsVdPk) and after this video ended I need to automatically display a second ...

I need to make a video page for my website which must contain a video from youtube (https://www.youtube.com/watch?v=bWPMSSsVdPk) and after this video ended I need to automatically display a second ...

  1. make youtube replay automatically
  2. make youtube repeat automatically
  3. how to make youtube automatically play 1080p
  4. make youtube video play automatically on facebook
  5. make youtube video play automatically in powerpoint
  6. how to make youtube automatically play highest quality
  7. make youtube video replay automatically
  8. how to make youtube automatically play next video
  9. make youtube video play automatically on website
  10. make youtube video play automatically
  11. make youtube video repeat automatically