Tuesday, March 25, 2014

Remove attribute from html using javascript, webdriver, python

EXAMPLE:
<tag id="id" name="name" class="class" readonly="readonly">EXAMPLE</tag>

self.find_elem_by_id("id").get_attribute("innerHTML") => EXAMPLE
self.find_elem_by_id("id").get_attribute("outerHTML") => <tag id="id" name="name" class="class" readonly="readonly">EXAMPLE</tag>

self.driver.execute_script('document.getElementById("id").removeAttribute("readonly")') => <tag id="id" name="name" class="class">EXAMPLE</tag>

4 comments:

  1. we provides you a best equity, Share Market Advisory tips in stock market. which gives opportunity for performing trading in share market and makes profit in short-term basis or invest money in long-term. In Trading you are make money and improve your lifestyle.
    stock tips

    ReplyDelete
  2. Nifty Calls along with Bank Nifty Tips You would be getting complete strategy along with Targets & SL. We Provide Best Intraday Sureshot Commodity Trading Tips.
    Share Market Tips

    ReplyDelete
  3. >>self.driver.execute_script('document.getElementById("id").removeAttribute("readonly")')

    Holy cow, this code does work!! It solves my problem, thanks a lot!!

    ReplyDelete

  4. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.When I started learning then I understood it has got really cool stuff.
    I can vouch webdriver has proved the best feature in Selenium framework.
    Thanks a lot for taking a time to share a wonderful article.

    Best Selenium Training Institute in Chennai |
    Selenium Training in Velachery

    ReplyDelete