I need to disable same-origin-policy for my autotests. I'm using webdriver.io + selenium standalone server + chromedriver on Ubuntu 16.04. I need to get title from iframe that has domain that differs from page domain. I have read this topic and used answers in my code, but it seems to not work/ Disable same origin policy in Chrome .
My code: Part of wdio.conf.js
capabilities: [{
maxInstances: 5,
browserName: 'chrome',
chromeOptions : {
args: ["--disable-web-security", "--user-data-dir:path/to/profile"]
}
}],
Part of my code in spec to get title of iframe:
it('step' , function() {
var iframeValue = browser.element('#iframe_id').value;
browser.frame(iframeValue);
browser.waitForExist('title'); //or any element inside head or body
browser.getTitle(); //returns page title, not iframe
browser.element('title').getText(); //returns ''
browser.element('title').getHTML(); //returns '<title>iframe title</title>'
});
I have restarted selenium server, restarted tests, used browser.debug() to check if iframe is an active element, checked that profile --user-data-dir parameter works. Is it possible that webdriver.io can't get values from iframe or --disable-web-security doesn't work at all?
UPDATE: Structure of iframe:
<iframe src="http://www.example.com" id="iframe_id"></iframe>
#document
<html>
<head>
<title>iframe title</title>
</head>
<body>
<div>
<!--content-->
</div>
</body>
</html>