0

I am trying to modify the class of an anchor tag from none to "active". This is the html:

<li class="item-1">
  <a href="#" class="active">
  </a>
</li>
<li class="item-1">
  <a href="#" class="">
  </a>
</li>

How can i change the class of the first

  • element to nothing and the class of the second
  • element to "active" using selenium in Python?

    I am looking for the following:

    <li class="item-1">
      <a href="#" class="">
      </a>
    </li>
    <li class="item-1">
      <a href="#" class="active">
      </a>
    </li>
    
    • Try webdriver.execute_script(). This will let you execute synchronus JS code within your python code. The best ways to change a class is answered here: https://stackoverflow.com/a/196038/8669719 – Knight May 25 '23 at 13:54

    0 Answers0