Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove an element attribute using Selenium and C#?

below is the chunk of html from which i want "disabled="disabled"" deleted and close the dev tools window. iam using selenium-webdriver with c#. Thank you.

<a class="btn btn-success" href="javascript:;" id="SendRFQ" data-loading-text="<i class='fa fa-spinner fa-spin'></i> Processing..." disabled="disabled" onclick="return SubmitRequisitionData(&quot;Submitted&quot;)">Click to Submit</a>
like image 992
ArK Avatar asked Sep 11 '25 16:09

ArK


1 Answers

Try below code to remove attribute from element

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("document.querySelector('a.btn.btn-success').removeAttribute('disabled')");

P.S. Note that real user will not modify HTML DOM to make link enabled, so if you need your script to simulate user-like behavior you should find another approach to make element enabled...

like image 113
Andersson Avatar answered Sep 14 '25 07:09

Andersson