0

I am trying to run a Selenium script that I created using Python bindings as an executable on a remote headless machine. The problem is that the scripts behaves differently when executed remotely.

I have done the following steps:

  1. Created a Selenium script (with Python bindings) that works perfectly on my local virtual machine.
  2. Transformed the above mentioned script into an standalone executable using py2exe. This one works on my local machine as expected as well.
  3. Run the created standalone executable on a remote VM that is absolutely similar to the one I was developing and testing the initial script on (in step 1). The only difference is that it's headless. For remote run I am using PsExec from PSTools utilities set. I run it in the following way:

    PsExec.exe \vmcle001iso -u rhdwa\he119712a -p Password123 -h c:\dist\test.exe

This is when my problems start. The first thing I've mention that some of Python commands stopped working. For example, usual Pythin exit(0) return with error:

Traceback (most recent call last):
  File "nacs.py", line 103, in <module>
NameError: name 'exit' is not defined

But my main problem that some of the elements become unable to find or interact with. Thus, certain buttons that worked perfectly before, return with Selenium exceptions like:

WebDriverException: Message: u'unknown error: Element is not clickable at point (960, 23). Other element would receive the click:

So just to emphasize that again, it all happens just when I run the executable remotely. Most of the code works as expected though.

Any hints to what might cause such behavior are very welcome.

Eugene S
  • 6,709
  • 8
  • 57
  • 91
  • Your remote machine probably "behaves" differently during the process of HTTP communication. For example, the connection might be different, web-site caching issues, DNS, etc. All that and many more would eventually yield different performance on the remote machine, which, if you had on your local machine would probably yield the exact same error that you're experiencing on the remote machine. Publish your code, as well as the URL of the web-page that you are trying to access (or at least the relevant piece of HTML), and we might be able to help you further. – barak manos Aug 06 '14 at 08:22
  • @barakmanos Hi and thanks for your prompt reply. The thing is that all these VMs are absolutely similar as they were cloned from the same image. The only difference between the one I am working on an the rest is that I am actually have a screen when remoting to it. Unfortunately I am unable to provide the URL since it's an internal commercial application which is actually a web service written with extjs (which is pain by itself). Additionally, as I mentioned, certain simple Python built-in command do not work either (like `exit(0)`) which makes me think there might be some deeper issue? – Eugene S Aug 06 '14 at 08:42
  • Without providing any additional information on your code (which uses Selenium) and the HTML that is "fed into it", I cannot help you further. – barak manos Aug 06 '14 at 08:45
  • @barakmanos I will cut out a specific piece that seems to behave differently and add it to my answer. Thanks! – Eugene S Aug 06 '14 at 08:46
  • You mean, your question... – barak manos Aug 06 '14 at 08:47
  • BTW, according to your own description, the local machine differs from the remote machine, as one is local and one is remote, so they are obviously not connected to the same LAN to begin with (and as I mentioned in my first comment, that implies multiple configuration-differences, such as DNS for example)... – barak manos Aug 06 '14 at 08:50
  • And BTW, the error message implies that your headless web-driver is configured to a different window size on each machine. – barak manos Aug 06 '14 at 08:52

1 Answers1

0

I feel this information is best contained in a comment, but I don't have those privileges yet, so this is what I found thus far.

I found this link which talked about the exit function- essentially, it's not recommended for scripts not run in the main interpreter because not as many modules are loaded upon startup, causing it not to be defined. (so it seems is not always built-in, as you had thought)

As far as the second error message, it seems that your code is loading some things faster/slower than before so it is getting to certain points before it can load a certain element- if I had to guess what would cause that, it would likely be too little time for a driver.sleep() command. Instead of changing these times manually, however, I would advise inserting WebDriverWaits (That's a link you can click on) to ensure that the element is clickable at that time. If the waits don't work and time out, it could also be something else affected.

Please update your post whenever you can so we can give more relevant information.

Community
  • 1
  • 1
punyidea
  • 173
  • 1
  • 9