1

I've been working on an automation script with selenium, after developing it locally I was able to make it consistently work on my local browser, however, I would like to set up the file to run on pythonanywhere.com. So I uploaded the code and ran it from there. However, when I run the code I come with an error Message: Element is disabled and so may not be used for actions. The element must be correct and interactable with since it worked perfectly locally on my firefox browser, it may be because of version differences in the firefox but I don't think so. I've seen answers for this on Stack but they say that the element is wrong, which shouldn't (but may) apply in my case. I am able to successfully grab the title from the website.

I won't be able to share the code due to the sensitivity of the process, but I can share that's it's a google form and the full error message, any help will be gratefully appreciated.

Thank you

Message: Element is disabled and so may not be used for actions
Stacktrace:
    at fxdriver.preconditions.enabled (file:///tmp/tmpi99ptn1x/extensions/fxdriver@googlecode.com/components/command-processor.js:10098)
    at DelayedCommand.checkPreconditions_ (file:///tmp/tmpi99ptn1x/extensions/fxdriver@googlecode.com/components/command-processor.js:126
44)
    at DelayedCommand.executeInternal_/h (file:///tmp/tmpi99ptn1x/extensions/fxdriver@googlecode.com/components/command-processor.js:1266
1)
    at DelayedCommand.executeInternal_ (file:///tmp/tmpi99ptn1x/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
    at DelayedCommand.execute/< (file:///tmp/tmpi99ptn1x/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Salman B
  • 138
  • 11

1 Answers1

2

This error message...

Element is disabled and so may not be used for actions

...implies that the element with which you are trying to interact is disabled and hence cannot be used for actions.


Deep Dive

The relevant HTML and your code trials would have helped us to construct a cannonical answer. However, as you mentioned you were able to make it consistently work on my local browser but doesn't pythonanywhere.com at this junction it is worth to mention that Selenium tends to mock the User Actions and some among them are:

  • Sending Text : sendKeys("LiamHarries")
  • Special Keyboard Characters : sendKeys(Keys.ENTER) and sendKeys(Keys.RETURN)
  • Mouse Hover : moveToElement(element).perform()
  • Click : click()

All these User Actions are independent of the underlying and Hardware configuration. Hence if they run the same application they will behave the same.

You can find a detailed discussion in Chrome & Firefox on Windows vs Linux (selenium)


This error

This issue have been discussed earlier in the thread Selenium webdriver :org.openqa.selenium.InvalidElementStateException: Element is disabled and so may not be used for actions where it was pretty much apparent that OP was trying to probe if the element driver.findElement(By.xpath("//input[@id='gs_htif0']")) was enabled.

Definitely, the based on the value of id attribute gs_htif0 wasn't a static one and hence it is bound to change periodically and may be available/unavailable in indigenous systems.

Solution

In these cases the solution is to construct the Locator Strategy based on static values of attributes.


References

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks so much for replying, I've sent a message to you on Facebook detailing the source code, I would really appreciate any help you could give – Salman B Jul 12 '20 at 10:33
  • 1
    @SalmanB I have provided the most canonical answer considering the information provided within the question. – undetected Selenium Jul 12 '20 at 14:10
  • Thanks so much for your time but would you mind taking a look at the message I sent you on Facebook, I can't say you answered it because I'm still not sure what to do, I've provided my entire code to you as a file on there, would greatly appreciate any help – Salman B Jul 13 '20 at 07:56