Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a Selenium function in an Python / SST automation script

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()
like image 656
Daemon Avatar asked Feb 26 '26 02:02

Daemon


1 Answers

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()
like image 75
Corey Goldberg Avatar answered Feb 27 '26 15:02

Corey Goldberg