Enable Disabled Button with no ID? Automation blocker!


#1

Hi, im trying to monipulate JS on the website so i can enable a button that is disabled
the button code is :

<button class="btn btn-primary create-account-button disabled" data-effect="ripple" data-wdio="createAccountButton" disabled="">

How can i enable it ?

I’ve tried :
runScript | document.getElementsByClassName("btn btn-primary create-account-button disabled").disabled = false;

But it just returns:
#### [error] Element is not found.

EDIT:
Managed to turn the button on, but theres some automation blocking scripting going on, that does not give the button “onClick” action unless a real physical click is performed on the page :frowning:


#2

getElementsByClassName returns an array. Try referencing the first element in the array. getElementsByClassName("className")[0]

In your case:

runScript | document.getElementsByClassName("btn btn-primary create-account-button disabled")[0].disabled = false;

#3

hello,

what about this
def y = WebUI.executeJavaScript("return document.getElementsByClassName('class-name')[0].disabled=false;", null)
println ("DEBUG readOnly value y "+y)

#4

IM trying all i can to get past this form:
https://www.homeaway.com/lyp/create-account
I think there is some sort of automation blocker on it ?


#5
Hello,

which button is disabled?

#6

Hello,

tried with these values no issues to press button
WebUI.openBrowser('https://www.katalon.com/')
def driver = DriverFactory.getWebDriver()
String baseUrl = "https://www.katalon.com/"
selenium = new WebDriverBackedSelenium(driver, baseUrl)
selenium.open("https://www.homeaway.com/lyp/create-account")
selenium.click("id=firstName")
selenium.type("id=firstName", "Demo")
selenium.click("id=lastName")
selenium.type("id=lastName", "User")
selenium.click("id=phone")
selenium.type("id=phone", "401234567")
selenium.click("id=email")
selenium.type("id=email", "demo.user@gmail.com")
selenium.click("id=password")
selenium.type("id=password", "Qwerty123")
selenium.click("xpath=(.//*[normalize-space(text()) and normalize-space(.)='Contains a letter'])[1]/following::button[1]")

and able to see this page


#7

I can’t get that page to load. I even tried disabling my ad-blocker but nothing is shown. :frowning_face:
Maybe you could try a JavaScript click, something like:

runScript | document.getElementsByClassName("btn btn-primary create-account-button disabled")[0].click();

#8

If you used the “element finder” to navigate and select the fields to click, you probably have pased the automation blocker.
Try to clear cache and start fresh session. If you just run the test it will get stuck on Phone number field marked with red border and the “Get Estimate” button disabled.

Enabling the button via JS modification sort of works, but OnClick action is not performed :frowning:

It goes away immediately and button becomes clickable as soon as a single “real” click is done anywhere on the page.

Im trying this on Firefox using the Recorder ofcourse.


#9

Are you using recorder ? selenium commands work on it ?
I’ve re-produced your commands and my guess is you have clicked it somewhere manually, as without a click im getting the same result as my prev post :frowning: