ChromeSwitchFrame


 

ChromeSwitchFrame>session_id,method,reference,result

 

Switches the browsing context of a session created by ChromeStart to the specified frame or iframe.


 

method can be one of

index

element

empty string or null

If method is index, reference should be a number representing the index of the frame, where zero is the first frame. 


 

If method is element, reference should be an element ID returned by ChromeFindElements.


 

If successul result will be zero and the browsing context will change to the selected frame. Subsequent Chrome functions will act upon that frame.  


 

To return the context to the parent window leave method empty or use index with reference set to null.


 

See also: Chrome Functions

 

Example

 

Let>CHROMEDRIVER_EXE=c:\chromedriver.exe


 

//start a Chrome session

ChromeStart>session_id


 

//navigate to google.com

ChromeNavigate>session_id,url,https://www.mjtnet.com/contact.htm


 

//Find the frame

ChromeFindElements>session_id,xpath,//iframe[@src='/contact-form/formpage.html'],elements


 

//switch to the first frame (the one with the fields)

ChromeSwitchFrame>session_id,element,elements_1,res


 

//now anything we do is inside that frame so we should be able to get the name field and enter something

ChromeFindElements>session_id,id,name,inputs

ChromeSetElementValue>session_id,inputs_1,john doe


 

//Switch context back to parent

ChromeSwitchFrame>session_id,index,null,res