Hi,
while developing a process using Selenium steps I need to do a more complex operation than I can find in the available steps
I know I can use the Script Step for Selenium as well and I need to reference the web driver in every Script Step that I use
When I open the browser with the Open Selenium step the driver I gave a variable name for the driver being used by the browser but I can’t reference it in the Script Step (?)
How can I access the driver for the already opened Selenium browser so I can do the operation in that already opened browser through Script?
- Roko asked 1 year ago
- You must login to post comments
You can reference the selenium in Script step using following code:
IWebDriver driver = (IWebDriver)VR[“_selenium_driver_script_reference_driverReferenceEdge”];
You need to replace “driverReferenceEdge” with the name of your output variable in Open Selenium Step.
After getting the reference to the web driver you can perform any selenium operation. I found it very useful if in the process I have to interact with elements that are in an iframe. This code switches the context to an iframe and then you can use the built-in selenium steps to interact with the iframe (Click Selenium Step etc.):
IWebDriver driver = (IWebDriver)VR[“_selenium_driver_script_reference_driverReferenceEdge”];
WebDriverWait waitSearch = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
//Store the web element
IWebElement iframe = waitSearch.Until(ExpectedConditions.ElementIsVisible(By.Id(“ifr”)));
//Switch to the frame
driver.SwitchTo().Frame(iframe);
- Darko Jovišić answered 1 year ago
- last edited 1 year ago
- You must login to post comments
Please login first to submit.