Permission issue with Selenium in Sikuli

Asked by Sam

Hi, just wanted to start out with a huge thank you to the Sikuli team and RaiMan for developing such a powerful platform. I'm very new to Sikuli and python programming but I've managed to a do a lot of very useful test automation work recently with Sikuli. I'm now trying to automate my tasks further by integrating selenium into the IDE. I couldn't find a lot of answers about how to make this work, so I followed some ideas laid out in a fairly ancient post I found herehttps://answers.launchpad.net/sikuli/+question/248040.

I installed selenium with pip and then took the folders installed by pip in the python 2.7 path and copied that into a new "Lib" folder I made in my SikuliX folder. The IDE seems to import selenium but now I'm having trouble with getting webdriver off the ground.

Here's the exception in its ugly verbatim:

[error] script [ Active projects ] stopped with error in line 1324
[error] shutil.Error ( [('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\components', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\components', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\components'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\content', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\content', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\content'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform\\WINNT_x86-msvc\\components', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform\\WINNT_x86-msvc\\components', "[Errn

o 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform\\\\WINNT_x86-msvc\\\\components'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform\\WINNT_x86-msvc', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform\\WINNT_x86-msvc', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform\\\\WINNT_x86-msvc'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\resource\\modules', u'C:\\Users\\Pro

gman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\resource\\modules', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\resource\\\\modules'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\resource', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\resource', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\resource'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>'")] )
[error] --- Traceback --- error source first line: module ( function ) statement 208: shutil ( copytr

ee ) shutil.Error: [('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\components', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\components', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\components'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\content', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\content', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\content'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform\\WINNT_x86-msvc\\components', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform\\WINNT_x86-msvc\\components', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Loc

al\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform\\\\WINNT_x86-msvc\\\\components'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform\\WINNT_x86-msvc', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform\\WINNT_x86-msvc', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform\\\\WINNT_x86-msvc'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\platform', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\platform', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\platform'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\resource\\modules', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>

om\\resource\\modules', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\resource\\\\modules'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi\\resource', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>\\resource', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>\\\\resource'"), ('C:\\Users\\Progman\\AppData\\Local\\Temp\\tmp0eadvc.webdriver.xpi', u'C:\\Users\\Progman\\AppData\\Local\\Temp\\tmpdpeped\\extensions\\<email address hidden>', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\AppData\\\\Local\\\\Temp\\\\tmpdpeped\\\\extensions\\\\<email address hidden>'")]
284: firefox_profile ( _install_extension ) shutil.copytree(addon, addon_path, symlinks=True)
92: firefox_profile ( add_extension ) self._install_extension(extension)

50: extension_connection ( __init__ ) self.profile.add_extension()
79: webdriver ( __init__ ) executor = ExtensionConnection("127.0.0.1", self.profile,
[error] --- Traceback --- end --------------

I'm running Sikuli 1.1.0 on a windows 7 machine with both python 2.7 and 3.5 installed.

Any advice on how to get webdriver up and running in my Sikuli project would be awesome.

Thanks.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

--- 1. Python itself is not relevant for SikuliX.
internally it uses Jython as Python language interpreter (Java based).

--- 2. Copying Python modules to the Sikuli environment
the solution you chose is principally ok, but depending on the Python environment you chose at pip time (2.7 or 3+), the installed modules might not work with SikuliX 1.1.0, which is at Python language level 2.5 and Jython 2.5 has many incompatibilities especially towards Python 2.7.

You should try with SikuliX 1.1.1 (http://sikulix.com), which contains Jython 2.7 and has some options especially for integrating compatible Python modules without the need to copy anything (http://sikulix-2014.readthedocs.io/en/latest/scenarios.html#access-python-packages-from-sikulix-scripts-run-by-sikulix-gui-or-commandline).

Revision history for this message
Sam (pancheafilm) said :
#2

Thanks for the quick response. I went ahead and updated to 1.1.1. I saw and tried to install the selenium4sikuli.jar into Extensions, however when accessing extensions from tools in the IDE I get the message "none available." Then I followed the python packages link and attempted to put selenium into a site-packages folder within Lib. I couldn't find a folder SikuliRepo so I placed the selenium folder into the Lib folder right at the main C:\Users\Progman\AppData\Roaming\Sikulix path. This produced a very similar exception like I originally posted when parsing webdriver.

[error] script [ Wincrafter 1.1.1 ] stopped with error in line 1324
[error] shutil.Error ( [('C:\\Users\\Progman\\appdata\\local\\Temp\\tmpysoftt.webdriver.xpi\\components', u'C:\\Users\\Progman\\appdata\\local\\Temp\\tmpl7en4q\\extensions\\<email address hidden>\\components', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\appdata\\\\local\\\\Temp\\\\tmpl7en4q\\\\extensions\\\\<email address hidden>\\\\components'"), ('C:\\Users\\Progman\\appdata\\local\\Temp\\tmpysoftt.webdriver.xpi\\content', u'C:\\Users\\Progman\\appdata\\local\\Temp\\tmpl7en4q\\extensions\\<email address hidden>\\content', "[Errno 1] Operation not permitted: u'C:\\\\Users\\\\Progman\\\\appdata\\\\local\\\\Temp\\\\tmpl7en4q\\\\extensions\\\\<email address hidden>\\\\content'"), ('C:\\Users\\Progman\\appdata\\local\\Temp\\tmpysoftt.webdriver.xpi\\platform\\WINNT_x86-msvc\\components', u'C:\\Users\\Progman\\appdata\\local\\Temp\\tmpl7en4q\\extensions\\<email address hidden>\\platform\\WINNT_x86-msvc\\components', "[Err

Am I missing something obvious?

Revision history for this message
masuo (masuo-ohara) said :
#3

I introduce my solution to use Selenium-webdriver from SikuliX-IDE.
The following is an example of using chrome as a browser.

[preparation:]
(1)Download Selenium Standalone Server(e.g. selenium-server-standalone-2.53.1.jar)
   Place selenium-server-stand\alone-2.53.1.jar at C:\Selenium
(2)Download chromedriver(e.g. chromedriver.exe)
   Place chromedriver.exe at C:\Selenium

[script code:]
load("C:\Selenium\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.chrome.ChromeDriver as CD
import org.openqa.selenium.chrome.ChromeDriverService as CS
import java.lang
java.lang.System.setProperty(
        CS.CHROME_DRIVER_EXE_PROPERTY,
        "C:\Selenium\chromedriver.exe")

driver = CD()
driver.get("http://www.sikuli.org/")
sleep(10)
driver.quit()

[environment:]
OS:Windows10
SikuliX:SikuliX1.1.1

Revision history for this message
Sam (pancheafilm) said :
#4

Thanks Masuo, I'm using firefox on a win7 machine, could you please advise me on an equivalent approach for firefox? Firefox functionality is built into the Selenium server correct? What would the commands to implement the firefox webdriver be in the vein you mentioned for chrome? I have Selenium Server downloaded and referenced in my Sikuli project.

Revision history for this message
masuo (masuo-ohara) said :
#5

The following is an example of using firefox as a browser.

[preparation:]
Download Selenium Standalone Server(e.g. selenium-server-standalone-2.53.1.jar)
Place selenium-server-stand\alone-2.53.1.jar at C:\Selenium

[script code:]
load("C:\selenium\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.Dimension as Dm

driver = FD()
sleep(10)
driver.get("http://www.sikuli.org/")
size = Dm(500,500)
driver.manage().window().setSize(size)
sleep(10)
driver.quit()

[environment:]
OS:Windows7
SikuliX:SikuliX1.1.1

Revision history for this message
Sam (pancheafilm) said :
#6

Definite progress! I put that code in at the browser phase of my script and it gets me into firefox very fast. At this point I seem to get two issues. The first is that the firefox instance it opens is totally vanilla. A major objective of the script in fact is to test a firefox plugin I have installed. How would I link the selenium instance of firefox to my full plug-in-extended version? The second issue is a straight ahead exception. 10 seconds after successfully loading the vanilla instance of firefox, seemingly as Sikuli begins to parse the rest of the not-selenium script, it throws this -

[error] JythonSupport: load: could not be found - even not in bundle nor in Lib nor in Extensions

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: "updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1466734942000,"updateDate":1466734942000,"applyBackgroundUpdates":1,"skinnable":true,"size":22012,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"47.0.1","maxVersion":"47.0.1"}],"targetPlatforms":[],

"seen":true}
1471777753289 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1471777753291 DeferredSave.extensions.json DEBUG Save changes
1471777753291 addons.xpi DEBUG Updating database with changes to installed add-ons
1471777753291 addons.xpi-utils DEBUG Updating add-on states
1471777753295 addons.xpi-utils DEBUG Writing add-ons list
1471777753304 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471777753304 addons.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.0
1471777753304 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471777753305 addons.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.0.2
1471777753306 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471777753307 addons

.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.3.2
1471777753343 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1471777753344 addons.manager DEBUG Provider finished startup: XPIProvider
1471777753344 addons.manager DEBUG Starting provider: LightweightThemeManager
1471777753344 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1471777753345 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1471777753345 addons.manager DEBUG Starting provider: GMPProvider
1471777753362 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1471777753363 addons.manager DEBUG Provider finished startup: GMPProvider
1471777753363 addons.manager DEBUG Starting provider: PluginProvider
1471777753363 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1471777753363 addons.manager DEBUG Provider finished startup: PluginProvider
1471777753363 addons.manager DEBUG Completed startup sequence
147177775513

0 addons.manager DEBUG Starting provider: <unnamed-provider>
1471777755130 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1471777755131 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1471777755837 DeferredSave.extensions.json DEBUG Write succeeded
1471777755837 addons.xpi-utils DEBUG XPI Database saved, setting schema version preference to 17
1471777755837 DeferredSave.extensions.json DEBUG Starting timer
1471777755861 DeferredSave.extensions.json DEBUG Starting write
1471777755864 addons.repository DEBUG No addons.json found.
1471777755865 DeferredSave.addons.json DEBUG Save changes
1471777755872 DeferredSave.addons.json DEBUG Starting timer
1471777755965 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1471777755965 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1471777755965 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1471777755970 DeferredSave.addons.json DEBUG Star

ting write
1471777755991 DeferredSave.extensions.json DEBUG Write succeeded
1471777756140 DeferredSave.addons.json DEBUG Write succeeded

at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:275)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Sourc

e)
at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)
at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:180)
at org.python.core.PyObject.__call__(PyObject.java:419)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:223)
at org.python.core.Deriveds.dispatch__init__(Deriveds.java:19)
at org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java:1112)
at org.python.core.PyType.type___call__(PyType.java:1713)
at org.python.core.PyType.__call__(PyType.java:1696)
at org.python.core.PyObject.__call__(PyObject.java:445)
at org.python.core.PyObject.__call__(PyObject.java:449)
at org.python.pycode._pyx1843.f$0(C:\Users\Progman\Desktop\SikuliX 1.1.1\Wincrafter 1.1.1.sikuli\Wincrafter 1.1.1.py:1410)
at org.python.pycode._pyx1843.call_function(C:\Users\Progman\Desktop\SikuliX 1.1.1\Wincrafte

r 1.1.1.sikuli\Wincrafter 1.1.1.py)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1386)
at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:286)
at org.sikuli.scriptrunner.JythonScriptRunner.runPython(JythonScriptRunner.java:206)
at org.sikuli.scriptrunner.JythonScriptRunner.runScript(JythonScriptRunner.java:175)
at org.sikuli.ide.SikuliIDE$ButtonRun$SubRun.run(SikuliIDE.java:2541)
at java.lang.Thread.run(Unknown Source)
Aug 21, 2016 7:10:03 AM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@10af52a

[error] script [ Wincrafter 1.1.1 ] stopped with error in line 1451
[error] Driver info ( driver.version: FirefoxDriver )

What do you guys make of it?

Thanks!

Revision history for this message
Sam (pancheafilm) said :
#7

Just to add a bit more information:

The exception throws at, driver = FD()

                 load("C:\selenium\selenium-server-standalone-2.53.1.jar")
                 import org.openqa.selenium.firefox.FirefoxDriver as FD
                 import org.openqa.selenium.Dimension as Dm

 ------> driver = FD()
                sleep(10)
                driver.get("http://www.sikuli.org/")
                size = Dm(500,500)
                driver.manage().window().setSize(size)
                sleep(10)
                driver.quit()

Revision history for this message
Sam (pancheafilm) said :
#8

Continuing my research, the first issue with selenium starting a vanilla firefox instance is about profile selection. There seems to be plenty of examples of how to change the firefox profile with selenium webdriver, but not with the standalone. Is there an easy approach to getting selenium webdriver properly imported? Why do think I'm getting "Not available yet" when I attempt to load the selenium4sikuli extension? Is selenium4sikuli webdriver? I'm finding it very hard to get good search results for these questions. Thanks.

Revision history for this message
masuo (masuo-ohara) said :
#9

You can use FirefoxProfile Class to change firefox profile.
I think that the following codes is a outline to set profiles.
Because I do not know about arguments, I can not answer.

[codes:]
import org.openqa.selenium.firefox.FirefoxProfile as FirefoxProfile

profile = FirefoxProfile()
profile.setPreference(argument1, argument2)
driver = FD(profile)

Revision history for this message
RaiMan (raimund-hocke) said :
#10

--- about selenium4sikulix
Experimental: Play with Selenium
This is about a first step to better support the side-by-side usage of Selenium and SikuliX in scripts.
You might run a showcase with Selenium Firefox (take care you have the latest Firefox installed).

These are the steps (tested only on Mac and Windows):
- have a setup with a build version 2015-07-03+
- on a command line run java -jar setup....jar options extensions which will download and store the supporting jar
- in the IDE run a script containing only: runScript("git*selenium"), which will run a script from the net (https://github.com/RaiMan/SikuliX-2014/blob/master/TestScripts/selenium/selenium.py)

You might also download the selenium4sikulix jar from here: http://nightly.sikuli.de/selenium4sikulix.jar

Since information about usage are not yet in the docs, you have to look into the script, to get an idea.

The solution is based on the Selenium Java package and is currently prepared for Jython scripting. So there is no need to fiddle around with any Python packages, pip installs or Jython problems with the Python stuff.

Revision history for this message
Sam (pancheafilm) said :
#11

Sorry to keep going back to the well like this, but I can't seem to get this off the ground. There is really very scant relevant search information.

Here are the facts as I very partially understand them.

1. Both methods advised by RaiMan and Masuo are utilizing selenium RC. This means effectively selenium4sikuli.jar is the same as selenium-server-standalone-2.53.1.jar. Is this correct?

2. This mean Selenium 2 AKA Selenium Webdriver is still incompatible with Sikuli IDE?

This is important, because 90% of the search results I've been using to troubleshoot this are only relevant to Selenium 2.

Right now this is the code as it stands in the middle of my script:

load("C:\selenium\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.Dimension as Dm
profile = FirefoxProfile()
driver = FD(profile)
driver.get("http://www.google.com/")
size = Dm(500,500)
driver.manage().window().setSize(size)

This is opens firefox and then sits there on a generic private browsing page.
The command driver.get("http://www.google.com/") is seemingly ignored as well as the rest of sikuli code below it.

Clearly I am missing something extremely basic?

Pertaining to loading the profile, this is the java approach apparently http://learn-automation.com/default-firefox-profile-in-selenium/ it involves what appears to be a selenium functionality "ProfileIni" -

" import org.openqa.selenium.firefox.internal.ProfilesIni " etc

However, sikuli obviously doesn't respond to the pure java syntax. What would be the pythonic version of this approach?

Revision history for this message
masuo (masuo-ohara) said :
#12

By my solution, I use selenium-server-standalone-2.53.1.jar as API library.
selenium-server-standalone-2.53.1.jar file contains selenium webdriver Class.

There is a dependency of version between selenium webdriver and firefox.
If it does not work, Probabry that is a problem of dependency of version between selenium webdriver and firefox.
I have run script on the following environment.

[environment]
OS: Windows7
SikuliX: 1.1.1
Firefox: 47.0.1
selenium: selenium-server-standalone-2.53.1.ja

Revision history for this message
Sam (pancheafilm) said :
#13

Here's my current test script verbatim. In your identical environment of Win7, Sikuli: 1.1.1, Firefox 47.0.1

load("C:\selenium\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.Dimension as Dm

driver = FD()
driver.get("http://www.sikuli.org/")

size = Dm(500,500)
driver.manage().window().setSize(size)

driver.quit()

driver.get (url) is unresponsive, firefox sits on default private browser page for 30 seconds then yields the following exception.

-----------------------------------------------------------------------------------------------

[error] JythonSupport: load: could not be found - even not in bundle nor in Lib nor in Extensions

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: ,"syncGUID":"5p-2IkF_CkTX","location":"app-global","version":"47.0.1","type":"theme","internalName":"classic/1.0","updateURL":null,"updateKey":null,"optionsURL":null,"optionsType":null,"aboutURL":null,"icons":{"32":"icon.png","48":"icon.png"},"iconURL":null,"icon64URL":null,"defaultLocale":{"name":"Default","description":"The default theme.","creator":"Mozilla","homepageURL":null,"contributors":["Mozilla Contributors"]},"visible":true,"active":true,"userDisabled":false,"appDisabled":false,"descriptor":"C:\\Program Files (x86)\\Mozilla Firefox\\browser\\extensions\\{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi","installDate":1466734942000,"updateDate":1466734942000,"applyBackgroundUpdates":1,"skinnable":true,"size":22012,"sourceURI":null,"releaseNotesURI":null,"softDisabled":false,"foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":true,"locales":[],"targ

etApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"47.0.1","maxVersion":"47.0.1"}],"targetPlatforms":[],"seen":true}
1471956859491 addons.xpi DEBUG getModTime: Recursive scan of {972ce4c6-7e08-4474-a285-3208198ce6fd}
1471956859492 DeferredSave.extensions.json DEBUG Save changes
1471956859492 addons.xpi DEBUG Updating database with changes to installed add-ons
1471956859492 addons.xpi-utils DEBUG Updating add-on states
1471956859503 addons.xpi-utils DEBUG Writing add-ons list
1471956859521 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471956859522 addons.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.0
1471956859522 addons.xpi DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471956859522 addons.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.0.2
1471956859523 addons.xp

i DEBUG Registering manifest for C:\Program Files (x86)\Mozilla Firefox\browser\features\<email address hidden>
1471956859524 addons.xpi DEBUG Calling bootstrap method startup on <email address hidden> version 1.3.2
1471956859547 addons.manager DEBUG Registering shutdown blocker for XPIProvider
1471956859548 addons.manager DEBUG Provider finished startup: XPIProvider
1471956859548 addons.manager DEBUG Starting provider: LightweightThemeManager
1471956859548 addons.manager DEBUG Registering shutdown blocker for LightweightThemeManager
1471956859548 addons.manager DEBUG Provider finished startup: LightweightThemeManager
1471956859549 addons.manager DEBUG Starting provider: GMPProvider
1471956859579 addons.manager DEBUG Registering shutdown blocker for GMPProvider
1471956859579 addons.manager DEBUG Provider finished startup: GMPProvider
1471956859579 addons.manager DEBUG Starting provider: PluginProvider
1471956859579 addons.manager DEBUG Registering shutdown blocker for PluginProvider
1471956859580 addons.m

anager DEBUG Provider finished startup: PluginProvider
1471956859580 addons.manager DEBUG Completed startup sequence
1471956861409 addons.manager DEBUG Starting provider: <unnamed-provider>
1471956861409 addons.manager DEBUG Registering shutdown blocker for <unnamed-provider>
1471956861410 addons.manager DEBUG Provider finished startup: <unnamed-provider>
1471956861416 DeferredSave.extensions.json DEBUG Starting write
1471956861846 addons.repository DEBUG No addons.json found.
1471956861847 DeferredSave.addons.json DEBUG Save changes
1471956861859 DeferredSave.addons.json DEBUG Starting timer
1471956861994 addons.manager DEBUG Starting provider: PreviousExperimentProvider
1471956861994 addons.manager DEBUG Registering shutdown blocker for PreviousExperimentProvider
1471956861994 addons.manager DEBUG Provider finished startup: PreviousExperimentProvider
1471956861996 DeferredSave.extensions.json DEBUG Write succeeded
1471956861997 addons.xpi-utils DEBUG XPI Database saved, setting schema version p

reference to 17
1471956861997 DeferredSave.addons.json DEBUG Starting write
1471956862170 DeferredSave.addons.json DEBUG Write succeeded

at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:120)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:275)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Sourc

e)
at org.python.core.PyReflectedConstructor.constructProxy(PyReflectedConstructor.java:211)
at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:180)
at org.python.core.PyObject.__call__(PyObject.java:419)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:223)
at org.python.core.Deriveds.dispatch__init__(Deriveds.java:19)
at org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java:1112)
at org.python.core.PyType.type___call__(PyType.java:1713)
at org.python.core.PyType.__call__(PyType.java:1696)
at org.python.core.PyObject.__call__(PyObject.java:445)
at org.python.core.PyObject.__call__(PyObject.java:449)
at org.python.pycode._pyx4961.f$0(C:\Users\Progman\Desktop\SikuliX 1.1.1\Selenium debug.sikuli\Selenium debug.py:13)
at org.python.pycode._pyx4961.call_function(C:\Users\Progman\Desktop\SikuliX 1.1.1\Selenium debug.

sikuli\Selenium debug.py)
at org.python.core.PyTableCode.call(PyTableCode.java:167)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1386)
at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:286)
at org.sikuli.scriptrunner.JythonScriptRunner.runPython(JythonScriptRunner.java:206)
at org.sikuli.scriptrunner.JythonScriptRunner.runScript(JythonScriptRunner.java:175)
at org.sikuli.ide.SikuliIDE$ButtonRun$SubRun.run(SikuliIDE.java:2541)
at java.lang.Thread.run(Unknown Source)
Aug 23, 2016 8:55:09 AM org.openqa.selenium.os.UnixProcess$SeleniumWatchDog destroyHarder
INFO: Command failed to close cleanly. Destroying forcefully (v2). org.openqa.selenium.os.UnixProcess$SeleniumWatchDog@7c868

[error] script [ Selenium debug ] stopped with error in line 5
[error] Driver info ( driver.version: FirefoxDriver )

------------------------------------------------------------------------------------------------------------------------------------

Please advise further.

Revision history for this message
masuo (masuo-ohara) said :
#14

[error] JythonSupport: load: could not be found - even not in bundle nor in Lib nor in Extensions

Considering from this error, path string as argument of load() is not correct.
Where do you place selenium-server-standalone-2.53.1.jar file?

Revision history for this message
Sam (pancheafilm) said :
#15

I just corrected that with a more accurate path- load("C:\Users\Progman\Desktop\Selenium\selenium-server-standalone-2.53.1.jar"),
that seems to have been the least of the issue though. Zero change in behavior, just a slightly different exception.

There's the same huge traceback block then this:

[error] script [ Selenium debug ] stopped with error in line 5
[error] Driver info ( driver.version: FirefoxDriver )

I did the revert to firefox 47.0.1 and am using selenium 2.53.1, what do think the version incompatibility could be referencing?

Revision history for this message
RaiMan (raimund-hocke) said :
#16

--- load("C:\Users\Progman\Desktop\Selenium\selenium-server-standalone-2.53.1.jar")
... pythonically is simply wrong
... you either have to use double \
... or specify the path as raw string r"..."

Revision history for this message
Sam (pancheafilm) said :
#17

Ok, double backslash it is. Be that as it may, no change in behavior. The issue seems to be with the driver, seemingly a version issue.

[error] Driver info ( driver.version: FirefoxDriver )

However, compatibility has been accounted for with the recommendations by Masuo and yourself. Are there any further tests you recommend?

Revision history for this message
masuo (masuo-ohara) said :
#18

At the time of #13, path string as argument of load() is not correct?
Despite incorrect path string, error did not occurred in line 2 (import org.openqa.selenium.firefox.FirefoxDriver).

If so, FirefoxDriver Class have not been imported from selenium-server-standalone-2.53.1.jar.
I think that FirefoxDriver Class was imported from somewhere another file.

Probably FirefoxDriver Class is still imported from somewhere another file At the time of #15.

Revision history for this message
RaiMan (raimund-hocke) said :
#19

@masuo
yep, that's the consequence.

@Sam: you should carefully check your environment and maybe strip it down to nothing and then start again step by step adding things nedded.

Revision history for this message
RaiMan (raimund-hocke) said :
#20

Before the
driver = FD()

you should place
for e in sys.path(): print e

to see what you have on sys.path

and you might use (only with SikuliX 1.1.1)
RUNTIME.dumpClassPath()

to see the content of the Java classpath.

Revision history for this message
RaiMan (raimund-hocke) said :
#21

... and the load() command adds the jar to the END of the Java classpath, so the fact, that a correct path spec with load does not change anything, proofs, that something is on the Java classpath already, that causes the problems, because it is found before the stuff added by load()

Revision history for this message
Sam (pancheafilm) said :
#22

So thank you guys for all the answers up to this point. I was away for several days and didn't get a chance to respond here. RaiMan you were absolutely right about it being crossed installs. It was actually the selenium4sikuli.jar itself that was conflicting with the load. I figured this out as I was deleting everything with the name selenium, selenium4sikuli gave me "open in application" error and wouldn't let me delete it. After deleting it, driver.get does what's supposed to. However, at this point how do I integrate webdriver functionality (find element by class, name, xpath etc)? When I tried to call driver.find_element_by_class_name today I get this

[error] AttributeError ( 'org.openqa.selenium.firefox.FirefoxDriver' object has no attribute 'find_element_by_class_name' )

How do I proceed to be able to actually use the core functionality? This version of the selenium standalone 2.53.1 doesn't seem to give it to me after all, or is it called a different way?

Revision history for this message
masuo (masuo-ohara) said :
#23

When you use selenium-server-standalone-2.53.1.jar as API library, use java API instead of Python API.

[codes:]
load("C:\Selenium\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.By as By

driver = FD()
driver.get("http://sikulix-2014.readthedocs.io/en/latest/index.html")
driver.findElement(By.name("q")).sendKeys("12345")
sleep(20)
driver.quit()

Revision history for this message
Sam (pancheafilm) said :
#24

Frankly, I don't really grasp what that means in this context Masuo, but your code works, so thank you.

What exactly is org.openqa.selenium.By ?

 I will try to implement my test tomorrow and see if I stumble further or am free and clear.

Thanks again.

Revision history for this message
masuo (masuo-ohara) said :
#25
Revision history for this message
Sam (pancheafilm) said :
#26

I'm starting to feel more comfortable with selenium thanks to to all the links you've supplied me. The package system was a bit unintuitive at first and didn't match really any of the learning material I was finding elsewhere on the internet.

I seem to have one more odd exception I'm facing between me and full functionality.

Here my current test script.

load("C:\\Users\\Progman\\Desktop\\Selenium\\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.By as By
import org.openqa.selenium.firefox.FirefoxProfile as FirefoxProfile
import org.openqa.selenium.firefox.internal
import org.openqa.selenium.interactions
import org.openqa.selenium.interactions.ClickAction

profile = FD.FirefoxProfile('C:\\Users\\Progman\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\nWv4HBss.default')
profile.native_events_enabled = True
driver = FD(profile)
driver.get("http://www.google.com/")

My aim right now is to load my default firefox profile. When I call its path, this is the super obscure error I get -

[error] TypeError ( org.openqa.selenium.firefox.FirefoxProfile(): 1st arg can't be coerced to java.io.File )

My searches have yielded no intelligible results on this error. Any ideas?

Revision history for this message
masuo (masuo-ohara) said :
#27

Search net about selenium profile by using keywords.
e.g. "usage to get selenium profile"

Then learn relation between Class and Method .
http://seleniumhq.github.io/selenium/docs/api/java/index.html

Revision history for this message
Sam (pancheafilm) said :
#28

Masuo, I search my errors extensively before posting here. I have not found a method for resolving this exception using python commands for the webdriver-backed selenium-standalone implementation we've been discussing. If the exception is the result of a retarded mistake on my part, please give me a bit of context on how to understand it. Sikuli obviously has issues interacting with the pure Selenium Webdriver, which is why you put me on the path of loading the older standalone jar. But you and RaiMan have made me have to infer this conclusion without providing context. The resources for understanding webdriver-backed selenium standalone are sparse. Pure selenium 2 webdriver for python installed by pip, is the common variation and the vast majority of search results are only relevant to that. I have no familiarity with Java, and the mixing of APIs in this discussion is truly confusing. I have developed tests in Sikuli for months now without a hitch using my limited python knowledge. If you would, please give me a moment and walk me through the 101 of what I'm doing wrong here.

Revision history for this message
RaiMan (raimund-hocke) said :
#29

IMHO: in this snippet there is some naming inconsistency:

load("C:\\Users\\Progman\\Desktop\\Selenium\\selenium-server-standalone-2.53.1.jar")
import org.openqa.selenium.firefox.FirefoxDriver as FD
import org.openqa.selenium.By as By
import org.openqa.selenium.firefox.FirefoxProfile as FirefoxProfile # this is the profile class name: FirefoxProfile
import org.openqa.selenium.firefox.internal
import org.openqa.selenium.interactions
import org.openqa.selenium.interactions.ClickAction

# so this is wrong IMHO
#profile = FD.FirefoxProfile('C:\\Users\\Progman\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\nWv4HBss.default')
# and must be
profile = FirefoxProfile('C:\\Users\\Progman\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\nWv4HBss.default')

Revision history for this message
Sam (pancheafilm) said :
#30

That was just one phrasing of the five I've tried. This yields the identical response.

profile = FirefoxProfile('C:\\Users\\Progman\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\nWv4HBss.')

[error] TypeError ( org.openqa.selenium.firefox.FirefoxProfile(): 1st arg can't be coerced to java.io.File )

Revision history for this message
RaiMan (raimund-hocke) said :
#31

... ok, then you can try:

# add
import java.io.File as JFile

# and then use
profile = FirefoxProfile(JFile('C:\\Users\\Progman\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\nWv4HBss.'))

Revision history for this message
masuo (masuo-ohara) said :
#32

@Sam
at #30 comment
Did you do typo for Directory path name?
".default" is missing?

Revision history for this message
Sam (pancheafilm) said :
#33

The typo was a copy/paste artifact. RaiMan's JFile suggestion worked great. The whole Jython mixed API system is something I'm slowly getting my head around. Hopefully that's the end of my setup issues. Thanks again guys.

Revision history for this message
Maria Haris (mariaharis) said :
#34

I am trying to read the element by the xpath I get the attribute error although I was able to find the elements by id.

element = driver.findElement(By.XPATH,'//*[@id="view"]/a')

I am not able to click the page objects

Can you help with this problem?

Provide an answer of your own, or ask Sam for more information if necessary.

To post a message you must log in.