开发者

Launching selenium from python (subprocess.Popen vs. os.system)

I'm launching the selenium 2 jar file using subprocess.Popen in python when I'm bootstrapping my tests.

This works fine with FF but when I try to launch google chrome it fails to load the page (getting a "Aww, snap"-error), it tries to look for it's profile in a weird place: $SELENIUM_JAR/"/var/folders/Qg/QgltsVp+FL0PDThAc5yUeE+++TM/-Tmp-/customProfileDir2e33faaabf3d4fb18491510228814229"/Default/Bookmarks

As a test I tried launching selenium manually and that worked fine, next I tried using os.system instead and to my surprise that works just fine.

Using os.system has many drawbacks though such as not being able to kill selenium and also not capturing the output.

My open command looks like this:

self.p = subprocess.Popen(to_execute, env=os.environ, shell=True, cwd=self.path_to_selenium, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr开发者_开发技巧=subprocess.PIPE)

Where to_execute is java -jar selenium-server.jar -userExtensions user-extensions.js -port 4444

I can add that I've tried messing with shell=False, removing the stdio and also launching via `/bin/bash -c' with no different results

Any ideas on what I'm missing?


Try to set to_execute to a list instead of a string, like:

to_execute = [
    'java', 
    '-jar', 'selenium-server.jar',
    '-userExtensions', 'user-extensions.js',
    '-port', '4444']


I will simply accept that the problem is not related to python but rather my framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜