Multiple Domains in a Page
Web pages can contain frames and iframes loading from different domains. For example a news page from one domain may show facebook likes coming from the facebook domain. When frames or iframes in a page are loaded from a domain different from the parent page, Sahi needs to select the domain in the script to see the elements in the frame.
Sahi can target a particular domain using 2 APIs.
Select Domain
Section titled “Select Domain”Modes Browser
This action allows selecting a domain before performing further actions.
Parameters
| Name | Type | Description |
|---|---|---|
$domainIdentifier | stringoptional | Can be the domain name or a regular expression of it. To reference the base domain, omit this parameter or use null. |
Raw script
// switch to frame of domain www.domain1.com_selectDomain("www.domain1.com");// perform actions on frame_assertEqual("Link Test", _getText(_link(0))); // no mention of domain neededvar $href;_set($href, _link(0).href); // no mention of domain needed// orvar $href="_fetch(_link(0).href);" // no mention of domain needed...// switch back to domain of top frame_selectDomain();// perform actions on domain of top frame
// To reference a domain along with its protocol, pass the protocol also. Eg._selectDomain("https://www.domain1.com");Sahi Pro Classic API _selectDomain

