Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

New relic synthetics unabe to locate page elements

Posted on 2016-08-26
3
Medium Priority
?
119 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 60

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 7

Accepted Solution

by:
Craig Kehler earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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).
Suggested Courses

926 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