3

Any senior automation guys out there? I am writing an automation script using Python with SST and I am running into some limitations with SST. I would like to borrow a function from the standard Selenium library to use in my script in which I double click a line of text to highlight it. I create one instance of webdriver in the beginning of the script with SST and begin performing actions on a web page. My question is: is there any way I can share that instance with a Selenium function to perform this one action. I realize I could do the entire script in Selenium but the company I work for is committed to SST and that would not be accepted. I do not think anyone would mind if I threw one Selenium function in though. Since SST is built on Selenium, I figured there must be a new class that has been written which I can import to perform an action such as this. The code I would like to execute would look something like the following. But of course when I create the second instance of webdriver with Selenium, a new browser is opened and the scripts are then logically split in half. Any tips?

from sst.actions import *
from selenium import webdriver
from selenium.webdriver.firefox.webdriver import *
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import *

go_to('http:/yadayada.net/')
## perform a bunch of actions
text = ## get text element with SST

driver = webdriver.Firefox()
action = ActionChains(driver)
action.double_click(text)
action.perform()

1 Answer 1

2

To access the underlying webdriver, you want to reference:

sst.actions._test.browser

Here is an example of an SST script that uses the webdriver.Firefox instance directly:

import sst.actions

# a regular SST action
sst.actions.go_to('http:/testutils.org/sst')

# now using webdriver directly 
sst.actions._test.browser.get('http://www.python.org')

The example in your question could be written as:

from sst.actions import *
from selenium.webdriver.common import action_chains

go_to('http:/yadayada.net/')
## perform a bunch of actions
text = ## get text element with SST

driver = sst.actions._test.browser
action = action_chains.ActionChains(driver)
action.double_click(text)
action.perform()
Sign up to request clarification or add additional context in comments.

11 Comments

I tried what you suggested and got the error below. Not sure why it is not recognizing the class that I already referenced earlier in the code. I don't doubt it worked on your end, we may may just have some version descrepancy:
Please refer to my answer to the question. Thanks for your input, Corey. Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> driver = sst.actions._test.browser NameError: name 'sst' is not defined
Sorry, I though I had it figured out, which was create instance with SST (i.e. page = start('Firefox')), then reference that later in the code (i.e. driver = webdriver.page()). Neither way worked though. Not really convinced Selenium and SST can share an instance of webdriver since I cannot find any documentation saying so. So, still looking, thanks.
@Daemon, try the exact code in the first snippet of my answer. Also remember it is an sst "script", and must be run via 'sst-run', not directly in a python interpreter.
@Daemon, if you are still running into problems, also verify you are an the latest SST release (currently 0.2.4)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.