Solved

New relic synthetics unabe to locate page elements

Posted on 2016-08-26
3
76 Views
Last Modified: 2016-11-03
New Relic is sometimes unable to locate an element and i keep getting an error messages similar to this---Error: no such element: Unable to locate element: {"method":"css selector","selector":"div.buttons-set-login > button.button"}

I made cssselector to css but still it doe's not work i tried locating the element by its xpath and still i get an error. Am i limited to locating elements because i am not using  JavaScript syntax?

var By = $driver.By;
var driver = $browser;
    
   
    driver.get("http://www.iccsafe.org");
    driver.findElement(By.css("div.buttons-set-login > button.button")).click();
    driver.findElement(By.id("eWebLoginControl_TextBoxPassword")).clear();
    driver.findElement(By.id("eWebLoginControl_TextBoxPassword")).sendKeys("sdsdsdsd");
    driver.findElement(By.id("eWebLoginControl_TextBoxLoginName")).clear();
    driver.findElement(By.id("eWebLoginControl_TextBoxLoginName")).sendKeys("sdsdsdsd@ddsdsd.com");
    driver.findElement(By.id("eWebLoginControl_LoginGoButton")).click();
    driver.findElement(By.css("button.button.btn-cart")).click();
    driver.findElement(By.id("qty_45646")).click();
    driver.findElement(By.id("qty_45646")).clear();
    driver.findElement(By.id("qty_45646")).sendKeys("1");
    driver.findElement(By.css("button.button.btn-cart")).click();
    driver.findElement(By.linkText("Remove item")).click();
    driver.findElement(By.xpath("(//button[@type='button'])[6]")).click();

Open in new window

0
Comment
Question by:zubair k
3 Comments
 
LVL 55

Expert Comment

by:Julian Hansen
ID: 41772031
Is it is possible your code is running before the page is ready?

Have you tried putting your code in a window onload function

jQuery
$(function() {
   initialise(); 
});
function initialise() {
var By = $driver.By;
var driver = $browser;
   
   
    driver.get("http://www.iccsafe.org");
    driver.findElement(By.css("div.buttons-set-login > button.button")).click();
    driver.findElement(By.id("eWebLoginControl_TextBoxPassword")).clear();
    driver.findElement(By.id("eWebLoginControl_TextBoxPassword")).sendKeys("sdsdsdsd");
    driver.findElement(By.id("eWebLoginControl_TextBoxLoginName")).clear();
    driver.findElement(By.id("eWebLoginControl_TextBoxLoginName")).sendKeys("sdsdsdsd@ddsdsd.com");
    driver.findElement(By.id("eWebLoginControl_LoginGoButton")).click();
    driver.findElement(By.css("button.button.btn-cart")).click();
    driver.findElement(By.id("qty_45646")).click();
    driver.findElement(By.id("qty_45646")).clear();
    driver.findElement(By.id("qty_45646")).sendKeys("1");
    driver.findElement(By.css("button.button.btn-cart")).click();
    driver.findElement(By.linkText("Remove item")).click();
    driver.findElement(By.xpath("(//button[@type='button'])[6]")).click(); 
}

Open in new window

JavaScript
Using window.onload has side effects - you can overwrite what was there before - the jQuery solution does not have the same risk.
windows.onload = start();

function start() 
{
   initialise();
   // put any other onload handlers here
}

function initialise() {
   ...
   // As above
}

Open in new window

0
 

Author Comment

by:zubair k
ID: 41772044
I apologize i don't know what window onload is. The script I created is Java/Selenium my script works in eclipse but not in New Relic. I am not very knowledgeable in coding i can just create scripts in eclipse. My company has me starting New relic and i have been having trouble with it. Some scripts pass with no problems and others i get an error message displaying element cannot be found.
0
 
LVL 6

Accepted Solution

by:
Craig Kehler earned 500 total points
ID: 41772067
Replace
 driver.findElement(By.css("div.buttons-set-login > button.button")).click();

Open in new window

with
driver.findElement(By.linkText("Login")).click();

Open in new window


If you have the Selenium IDE installed you can select the particular line it recorded and click the drop down for "Target" to see alternate selectors it has detected. Eventually you will want to learn the basics of css and html so you can build your own selectors based on what should be most reliable. In the short term using the By.linkText locator will probably be easiest for you.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question