laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 258 forks source link

win64, selenium + Python 2.6.6 win32 - can't start #625

Open ghost opened 7 years ago

ghost commented 7 years ago

versions

Steps to reproduce the issue

I want to use SlimerJS with python + selenium:

    from selenium import webdriver

    f = r'c:\slimerjs'

    driver = webdriver.PhantomJS(executable_path=f)
    driver.set_window_size(1280,1024)
    driver.get('https://slimerjs.org')
    driver.save_screenshot('temp/screenie.png')

Actual results:

Traceback (most recent call last): File "bet365.py", line 10396, in test_slimer() File "bet365.py", line 10348, in test_slimer driver = webdriver.PhantomJS(executable_path=f, port=port, service_log_path=f_log) File "d:\server\usr\local\python\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 52, in init self.service.start() File "d:\server\usr\local\python\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start stdout=self.log_file, stderr=self.log_file) File "d:\server\usr\local\python\lib\subprocess.py", line 623, in init errread, errwrite) File "d:\server\usr\local\python\lib\subprocess.py", line 833, in _execute_child startupinfo) WindowsError: [Error 193] %1 эх  ты хЄё  яЁшыюцхэшхь Win32

Expected results:

It should be screenshot :)

I googled a little, and this error is from some kind mismatch of python version (in my case win32) and some library. I've tried with slimerjs-0.9.6-win32.zip and Mozilla Firefox v50 win32, but recieved the same problem.

ghost commented 7 years ago

I have some progress :)

The problem was with wrong path. I was sure that I just should use only file slimerjs, that's why I used line f = r'c:\slimerjs' in my code.

But after I've mode full directory c:\slimerjs-0.10.3\ and changed line to f = r'c:\slimerjs-0.10.3\slimerjs.bat' , I could start slimerjs from command line, like slimerjs.bat test.js In fact code from test.js runs successfully.

But I still have a problem with selenium. When I try to use it from selenium with code

from selenium import webdriver

f = r'c:\slimerjs-0.10.3\slimerjs.bat'

driver = webdriver.PhantomJS(executable_path=f)
driver.set_window_size(1280,1024)
driver.get('https://slimerjs.org')
driver.save_screenshot('screenie.png')

I get an error

c:\slimerjs-0.10.3>minimum.py
Traceback (most recent call last):
  File "C:\slimerjs-0.10.3\minimum.py", line 5, in <module>
    driver = webdriver.PhantomJS(executable_path=f)
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 52, in __init__
    self.service.start()
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\common\service.py", line 96, in start
    self.assert_process_still_running()
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\common\service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service c:\slimerjs-0.10.3\slimerjs.bat unexpectedly exited. Status code was: 0

Any ideas how to solve that?

ghost commented 7 years ago

And it's strange for me that I can't strart slimerjs like webdriver.

c:\slimerjs-0.10.3>slimerjs.bat --webdriver=localhost:9000 --webdriver-engine=ghostdriver --debug=yes --error-log-file=slimerjs.log
unknown option --webdriver=localhost:9000

Even the simplest variant return the same error:

c:\slimerjs-0.10.3>slimerjs.bat --debug=true
unknown option --debug=true

Is it ok?

ghost commented 7 years ago

I've setuped cygwin, and now able to work with real slimjs This works, executes hello.js : bash slimerjs hello.js But this bash slimerjs --webdriver=localhost:9000 --webdriver-engine=ghostdriver --debug=yes --error-log-file=slimerjs.log still do nothings (something blinks in some miliseconds, and the script exits).

I've created my own slimerjs_my.bat with content bash slimerjs %* that redirects all arguments to real slimerjs. After that I can use slimerjs_my.bat hello.js and it works.

But with selenium

from selenium import webdriver

f = r'c:\slimerjs-0.10.3\slimerjs_my.bat'

driver = webdriver.PhantomJS(executable_path=f)
driver.set_window_size(1280,1024)
driver.get('https://slimerjs.org')
driver.save_screenshot('screenie.png')

I get an error c:\slimerjs-0.10.3>minimum.py

Traceback (most recent call last):
  File "C:\slimerjs-0.10.3\minimum.py", line 5, in <module>
    driver = webdriver.PhantomJS(executable_path=f)
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 52, in __init__
    self.service.start()
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\common\service.py", line 96, in start
    self.assert_process_still_running()
  File "D:\server\usr\local\python\lib\site-packages\selenium\webdriver\common\service.py", line 109, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service c:\slimerjs-0.10.3\slimerjs_my.bat unexpectedly exited. Status code was: 0