Switch to frame Select a frame by its (zero-based) index driver.switchTo().frame(int index) Select a frame by its name or ID driver.switchTo().frame(String nameOrId) Select a frame by WebElement driver.switchTo().frame(WebElement frameElement) Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged driver.switchTo().parentFrame(); Selects either the first frame on the page, or the main document when a page contains iframes driver.switchTo().defaultContent(); Once we have switched to a frame, will need to switch to parent frame frist, and then switch to another frame under the same parent
During script development or debugging in selenium, if we can attach the code to an existing browser session, it will make things easier. Here is how to do it with Chrome.
Open chrome with remote debugging port "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 Start chrome driver WebDriver wdriver =null; ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("debuggerAddress", "127.0.0.1:9222"); driver = new ChromeDriver(options);
Usually we use ALM to manage our test cases, test script and resource files, which works very well, but when we consider to host the script in git, we have to download them to local and commit to git.
In this exercise, I try to download UFT scripts and resource files in UFT with using ALM OTA , the OTA api reference can be found here, and here is the code.
In TOSCA Distributed Execution, we discussed how to integrate TOSCA Distributed Execution with Team City, which we have two steps for triggering the execution. Since we need to use them for multiple build configuration, so considering to wrap them one step with Team City Meta-Runner.
The Meta-Runner can be extracted from an existing build configuration. In this case, open the build configuration to be extracted, and go to Actions -> Extract Meta-Runner, Enter or adjust values for Project, Name, ID, Description, and then click Extract button, then make changes if required.
This exercise will try out TOSCA Distributed Execution, the benefits of using it are
Supports untended execution, creates RDP connection automatically while execution Splits the execution load to multiple agent system Monitors the actual test execution with Test Event Monitor After installing the TOSCA 9.3, the Distributed execution components are under C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\DistributedExecution
Distribution Server For installing the distribution server, InstallServer.bat under DistributedExecution\Server should be executed,
parameter IP address & Port can be assigned if required.
After installing TOSCA 9.3, TOSCA CI related program should be under C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander\ToscaCI.
Preparation in TOSCA work space Create a execution list folder and set attribute ContinuousIntegrationBuildRootFolder to True Create execution list with attribute ContinuousIntegration=True and a desired value for Executiontype Add test cases which you plan to execute to this execution list. TOSCA CI Client TOSCA CI professional license is required for using CI configuration file.
Since we will trigger the execution from TeamCity, the TOSCA CI client could be triggered under system account, under that the UI automation will be blocked.
Lots of websites use JQuery, and JQuery selector has more features than Css locator, such as contains etc. So try to use Javascript Executor to execute JQuery selector and return the WebElements.
public static IEnumerable<IWebElement> FindElementsByJQuery(ISearchContext context, string locator) { var jsContext = context as IJavaScriptExecutor; if (jsContext != null) { var jObjects = (Dictionary<string,object>)jsContext.ExecuteScript(string.Format("return jQuery(\"{0}\")", locator)); foreach (var o in jObjects) { if (!(o.Value is IWebElement)) { continue; } yield return (IWebElement) o.
In Selenium, there are multiple locator functions, such as
By.CssSelector By.XPath By.Id By.Name …… In my case, I would like to use different format, which I can call one method instead of so many, it would be easier to store the locator information somewhere else. The locator format would be ByMethod = selector to Find, for example:
css=input[value=’clear’][type=button]
So an extension method was created for this, here is the code snippet.