Solved

New relic synthetics unabe to locate page elements

Posted on 2016-08-26
3
48 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 51

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now