Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Synthetic script fails to identify object


#1

Synthetics Question Template

I’ve had no luck identifying the object via id, xpath, or classname- or any nearby object.
Research into the issue shows that it’s like related to the iframe the object is located in.
However, trying to switch iframes doesn’t seem to worth either.
The following snippet works in another script, but not this one
Working code:
//Switch to iframe
.then(function() { return $browser.sleep(3000); })
.then(function(){
return $browser.findElement($driver.By.id(‘ptifrmtgtframe’)) //Find iframe
}).then(function(iframe) {
return $browser.switchTo().frame(iframe); //switch to iframe
})

//Switch to iframe
.then(function() { return $browser.sleep(3000); })
.then(function(){
return $browser.findElement($driver.By.id(‘ID_3828536612367975961’)) //Find iframe
}).then(function(iframe) {
return $browser.switchTo().frame(iframe); //switch to iframe
})

Switching it to a generic iframe ID does not yield results either.
The iframe ID was identified by identifying the object in question via the inspect function for chrome developer tools, and then scrolling up to find the name for the parent iframe.

Is there a code snippe to force new relic to find names for all potential iframes? Or simply create an array of iframe to step through?


#2

Does your search from developer tools yield only 1 result?

This is what I use (where ‘Frame’ is the name I get from developer tools):

//step 1
.then(function() {
  log(1, 'Find Logout Frame');
  return $browser.waitForAndFindElement(By.xpath('//frame[@name="Frame"]'), StepTimeout) 
})

//step 2
.then(function(el) {
  log(2, 'Switch to Logout Frame');
	return $browser.switchTo().frame(el);
})

#3

Hey there @johrice -

Just wondering if you had a chance to take a look at @monitoringLife’s idea and if that got you pointed in the right direction. We would love to know if and how you got this figured out.


#4

Thanks everyone!

The final version of the code we used is to basically skip identifying the frame entirely, and use a function to simply select the first one in the index

.then(function selectFrame() {
  var type = "index=0".split("=");
  var value;

  if (type[0] == "index") {
    value = parseInt(type[1]); // int type
  } else {
    value = type[1]; // string type
  }

  logger.log(7, "switch to frame  index=0");
  return $browser.switchTo().frame(value);
})

#5

Thank you so much for coming back to share your final solution @johrice. Nice work!