Selenium in sikuli

Asked by fernando gandini

Can any one help me to import selenium into sikuli. I saw others questions here in launchpad but i still have problens.
Many thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:

This question was reopened

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

What is your current approach?

Paste some snippets and talk about your config.

Revision history for this message
fernando gandini (fernando-gandini) said :
#2

Hi RaiMan,

actually i want some itens from selenium, like set elements from page by id or name, and wait until page loaded....
now i using "try find.images" on sikuli to put values and know if the page is loaded... but some times it works and some times dont.

thanks again

my system.
win 7 - 4gb
sikuli running on VM with low res desktop to improve the speed of seaching imagens.

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

--- you have to get the Selenium Python client and the Selenium server of course.

--- in a Sikuli script:
# at the beginning
selDir = "path-to-folder-containing-selenium.py"
if not selDir in sys.path: sys.path.append(selDir)
import selenium
reload(selenium) # if in run IDE

# get a session with a browser
browser = selenium("localhost", 4444, "*chrome", "http://www.google.co.in/")
browser.start()

# now you can do everything with the browser, the Selenium Python client allows.

Revision history for this message
fernando gandini (fernando-gandini) said :
#4

great RaiMan, i'll try that.
Many thanks

Revision history for this message
fernando gandini (fernando-gandini) said :
#5

hi folks, sorry but i have to reopen the question...

here is my code..is exactly the sane of Raiman

selDir = ""C:\Program Files\Sikuli X\selenium.py""
if not selDir in sys.path: sys.path.append(selDir)
import selenium
reload(selenium) # if in run IDE

browser = selenium("localhost", 4444, "*chrome", "http://www.google.co.in/")
browser.start()

and i getting the error:
TypeError: 'module' object is not callable

can any one help me...
thanks

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

Uuups, must be my fault (not the selenium expert ;-):

browser = selenium("localhost", 4444, "*chrome", "http://www.google.co.in/")

there seems to be something missing after the module name selenium, like

browser = selenium.??webdriver??("localhost", 4444, "*chrome", "http://www.google.co.in/")

The selenium Python docs should know it.

Revision history for this message
fernando gandini (fernando-gandini) said :
#7

thanks RaiMan, but stil not working :(

im look in Selenium Python docs, found some things, but stil not working!

Thanks anyway

Revision history for this message
Irina (gvozdi4ka85) said :
#8

I can import selenium into sikuli, the browser opened using selenium, but now problem for me when i use selenium - sikuli clicks or any other command doesn't work, I see it run in log, but in browser nothing hapened.
Any idea what it can be?
As soon as I use only sikuli command - all clicks work

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

@Irina
What system?

What Selenium? Webdriver?

Might be a focus problem (might be you have to make the target window active somehow before clicking)

Revision history for this message
Irina (gvozdi4ka85) said :
#10

Win7 64 bit, selenium RC . I still can't import driver to sikuli - have a lot of error when import modules.
I tried to click on browser window, when script is running so it's active

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

--- have a lot of error when import modules.
what exactly?

Revision history for this message
Irina (gvozdi4ka85) said :
#12

When I import selenium it's enogh do as you decsribe above:
selDir = "C:\\Python27\\Lib\\site-packages\\selenium"
if not selDir in sys.path:
     sys.path.append(selDir)
from selenium import selenium
Selenium working, but when I try to import driver it has a lot of modules to import:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
So may be I haven't correct sys.path?
it can import webdriver and stop at this line:
from selenium import webdriver

Message from Sikuli:
[error] Stopped
[error] An error occurs at line 4
[error] Error message: Traceback (most recent call last):
 File "C:\Users\Irina\AppData\Local\Temp\sikuli-tmp1797026541086595355.py", line 4, in
 from selenium import webdriver
 File "D:\Sikuli11\qmee_driver.sikuli\selenium\webdriver\__init__.py", line 18, in
 from firefox.webdriver import WebDriver as Firefox
 File "D:\Sikuli11\qmee_driver.sikuli\selenium\webdriver\firefox\webdriver.py", line 26, in
 from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
 File "D:\Sikuli11\qmee_driver.sikuli\selenium\webdriver\firefox\firefox_profile.py", line 27, in
 from selenium.webdriver.common.proxy import ProxyType
 File "D:\Sikuli11\qmee_driver.sikuli\selenium\webdriver\common\proxy.py", line 17, in
 class Proxy(object):
 File "D:\Sikuli11\qmee_driver.sikuli\selenium\webdriver\common\proxy.py", line 48, in Proxy
 @proxy_type.setter
AttributeError: 'property' object has no

attribute 'setter'

Thanks a lot for help

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

The problem seems to be, that you are using a selenium version for Python, that is written for Python language level 2.7

This seems to somehow conflict with the Jython used in Sikuli, which is on Python language level 2.5
The Selenium stuff expects a property object 2.7 and gets one tha is for 2.5

So you need a Selenium Python library that is compatible with language level 2.5 or you have to look for some Selenium setting, that forces compatibility with language level 2.5.

Revision history for this message
Irina (gvozdi4ka85) said :
#14

But why selenium rc work? It's also in python 2.7

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

Selenium RC is the older version and might not have any 2.7 specific features.

Webdriver is the actual follow-up for RC and so might have this problem.

You have to check. Not really a Sikuli problem (besides the fact, that Sikuli uses Jython, which is at language level 2.5)

You might decide to switch to the Java environment, where you will not have any problems.

Revision history for this message
Irina (gvozdi4ka85) said :
#16

It look like I have some focus problem (but I even click on browser after it opening - so browser window is active), I try java and it works with selenium driver, but for IE I need selenium RC - and click don't work for me even in Java - if I open browser using selenium and then use sikuli clicks. The click begin works if only I open browser using App.open() function,but then I can't use selenium.
Thanks

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

@ Irina
Might be a focus problem (Selenium RC does not make the started IE the frontmost, active app ???).

So try
App.focus("some IE window text")
before the click

Revision history for this message
Irina (gvozdi4ka85) said :
#18

doesn't help (