I'm realizing a script using Selenium Webdriver with Python to crawl some webpages, but I have a particular problem. At a certain point, I should take an input element and send a key, and on my local PC the script works well, while on my server this element results invisible. The HTML part of the page is:
<div class="class1" style="width: 309px;">
<div class="sPb-a">
<div class="class2" style="display: none;" aria-hidden="true">
www.lol.com
</div>
<input class="class3" type="text" dir="ltr" style="width: 301px;"></input>
</div>
<div></div>
</div>
In Python, this is my code:
elem = browser.find_element_by_xpath("//input[@style='width: 301px;']")
elem.clear()
time.sleep(1)
elem.send_keys('lol')
time.sleep(1)
But when I call the method clear on the element, the script catch the following error:
Element is not currently visible and so may not be interacted with
Stacktrace:
at fxdriver.preconditions.visible (file:///tmp/tmpma637_/extensions/fxdriver@googlecode.com/components/command-processor.js:9982)
at DelayedCommand.prototype.checkPreconditions_ (file:///tmp/tmpma637_/extensions/fxdriver@googlecode.com/components/command-processor.js:12626)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpma637_/extensions/fxdriver@googlecode.com/components/command-processor.js:12643)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpma637_/extensions/fxdriver@googlecode.com/components/command-processor.js:12648)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpma637_/extensions/fxdriver@googlecode.com/components/command-processor.js:12590)
I would like also to say some two additional information:
- There is only one element with width: 301px and this error happens also if I try to capture the element in another ways, so this element is unique
- The configuration between my local PC (where the script works well) and my server (where there is the problem) is the same (python version, selenium version, browser version, operating system version)
Do you know any solution? Thanks a lot