What is the correct way to insert a JSON object into a p
tag inside an iframe
?
I attempted the following approach but it displayed the text "[object Object]" rather than the actual content of the object...
This is my implemented code:
var arrJSON = [
{
"list": [
{
"pageRequest": "http://www.tmz.com/",
"fullRequest": "http://0914.global.ssl.fastly.net/ad/img/x.gif?cb=1487451360453",
"method": "GET",
"contentType": "image/gif",
"queryString": "cb=1487451360453",
"queryDelimiter": ""
}
],
"tagName": "DNStination Inc fastly.net",
"regex": "((ht|f)tp(s?)://)?(.*)fastly.net/ad/img/x.gif(.*)",
"domain": "fastly.net",
"logoUrl": "https://logo.clearbit.com/fastly.net"
},
{
"list": [
{
"pageRequest": "https://moz.com/",
"fullRequest": "https://092-obr-737.mktoresp.com/webevents/visitWebPage?_mchNc=1487448129811&_mchCn=&_mchId=092-OBR-737&_mchTk=_mch-moz.com-1487448129792-38969&_mchHo=moz.com&_mchPo=&_mchRu=%2F&_mchPc=https%3A&_mchVr=151&_mchHa=&_mchRe=&_mchQp=",
"method": "GET",
"contentType": "image/gif",
"queryString": "_mchNc=1487448129811&_mchCn=&_mchId=092-OBR-737&_mchTk=_mch-moz.com-1487448129792-38969&_mchHo=moz.com&_mchPo=&_mchRu=%2F&_mchPc=https%3A&_mchVr=151&_mchHa=&_mchRe=&_mchQp=",
"queryDelimiter": "&"
}
],
"tagName": "Marketo, Inc mktoresp.com",
"regex": "((ht|f)tp(s?)://)?(.*)mktoresp.com/webevents/visitWebPage(.*)",
"domain": "mktoresp.com",
"logoUrl": ""
}
];
var webdriver = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome');
const util = require('util');
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
driver.get('https://my_site.com');
for(i=0; i<arrJSON.length; i++){
driver.get('https://my_site.com/page');
driver.wait(until.titleIs('Title'), 2000);
var element = driver.findElement(By.css('option[value=\'Tags\']')).click();
var string1 = JSON.stringify(arrJSON[i]);
driver.executeScript('document.querySelectorAll(\'iframe\')[0].contentDocument.querySelector(\'p\').innerHTML = ' + string1);
driver.sleep(2000);
}