Unexpected Exception: TypeError: window.document.getElementById(...) is null.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected Exception: TypeError: window.document.getElementById(...) is null.

fpauloc
HI all,

I'm trying to grab an element using its ID by issuing a javascript command in Selenium IDE:

                   javascript{document.getElementById('btnsWishAddBuy').getElementsByClassName('buy-button')[0].dataset.id}

However, even though the ID i'm trying to find matches a correct ID
(when I view the page source), the command is returning null (on Selenium IDE).

Command work both in Firefox and Chrome.

Kann anyone help me?

Thanks

Code:
------------------------------

<div id="btnsWishAddBuy" class="col-xs-12">
<button id="articleToBasket" class="btn btn-lg addWish" data-id="101010">
<i class="pccom-icon">$</i><span>Add</span>
</button>
<button data-name="Asus ...." type="button" data-loading-text="Adding..." id="add-cart" class="btn btn-lg addCar btn-secondary-outline GTM-addToCart " data-id="101010" data-price="9" data-brand="Asus ..." data-category="Placas Base" data-qty="1">
<i class="com-icon">}</i>
<i class="com-icon arrow">yx</i>
<span>Add to ...</span>
</button>
<button type="button" data-loading-text="Adding ..." class="btn btn-primary btn-lg buy GTM-addToCart buy-button" data-name="Asus Rampage" data-id="101010" data-price="9" data-brand="Asus" data-category="Base" data-qty="1">
<strong>buy</strong>
<i class="com-icon">]</i>
</button>
</div>

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/53579756-fd55-49a4-a6f0-92056399c509%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected Exception: TypeError: window.document.getElementById(...) is null.

Akshat Gupta
Try in this manner

http://www.guru99.com/execute-javascript-selenium-webdriver.html


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c8b3bf95-bfc9-481b-8da5-0c02266ef136%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.