Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

New relic synthetics unabe to locate page elements

Posted on 2016-08-26
3
Medium Priority
?
106 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

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 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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
How many times a day do you open, acknowledge, or close an IT incident? What’s your process? Do you have a process depending on the incident, systems involved, and other factors? New Relic Alerts gives you options for how you interact with notifica…
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…
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…

719 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