2017-07-23 48 views
0

我試試切換幀,但它們的ID和Name屬性是動態的。我用webdriverio。我可以使用類名嗎?有任何想法嗎?按類名切換幀webdriverio

<iframe id="n33l4d68f0xr" class="KA-JQ" name="n33l4d68f0xr" src="https://docs.google.com/picker?protocol=gadgets&origin=https%3A%2F%2Fmail.google.com&hl=en&hostId=gmail-to&multiselectEnabled=true&navHidden=true&dff=0&authuser=0&title=Select%20contacts&relayUrl=https%3A%2F%2Fmail.google.com%2Ffavicon.ico&nav=((%22contacts%22))&rpctoken=fmac4onpwdet&rpcService=n33l4d68f0xr" tabindex="0" frameborder="0"> 

回答

0

你可以通過選擇所有的元素和先切換到這樣的:

// inside some async func 
const {value} = await browser.elements('.KA-JQ'); 
await browser.frame(value[0]); 

// or not async 
return browser.elements('.KA-JQ').then(iFrame => { 
    return browser.frame(iFrame.value[0]); 
});