Solved

New relic synthetics unabe to locate page elements

Posted on 2016-08-26
3
69 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 54

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 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