breakdown xpath - xpath

I am looking at the website. Trying to transfer selenium html to junit but could not get it to work because it keeps saying Error: Element not found. Maybe syntax error because I was able to break it down to the shortest path in firebug but still could not get to compile..What do you do in this case ?
Enrollment
I use firebug Xpath to get the value of the above link
/html/body/div[#id='contentDisplayPane']/div[#id='mainDiv']/div[#id='mainDivContent']/div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a
Using firebug xpath, I was able to break it down to this and able to access Enrollment link..However when I put this in the junit test case selenium.click(("//div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a");
I get ERROR: Element //div[#id='simpleBox']/table/tbody/tr[2]/td[#id='fb_PageContent']/table/tbody/tr/td/table/tbody/tr/td[4]/a") not found
Any help or tip is appreciated

Hey If you want to click any Link on your web page.
You have to first find Xpath of this Element/Text, For this you can use Firebug.So here an ex: You can use in IDE selenium.click(//a[text()="ON"]) and convert it to junit and get this
selenium.click("//a[text()=\"HereYouCanPutYourText\"]");
please feel free if you have any concern..

Are the tbody elements actually in the html or just being inserted by Firefox? If Firefox is inserting the tbody and your junit tests are driving a different browser, the tbody might not be there. Just a shot in the dark since you didn't post the document you're testing, but maybe it'll help.

Related

handling dynamic pop-up error message in jmeter

I have a Jmeter script for an application for which i get pop up error message intermittently. Where as in jmeter we only come to know that flow got terminated by some failure.But we wont come to know the occurrence of Error pop -up message.
My requirement is if we encounter pop up error i want to write to an external file saying that ,the current page got failed due to pop-up error message.
If we can write the error message it's really great. I'm as of now not getting idea to achieve this.
Please can anyone help me in this. or can provide any hint to do R&D.
Thankyou in advance.
Updated the question with screen shot of error message.
As per JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
Looking into your screenshot, it is a form of JavaScript popup, most likely window.alert so there is no way to detect it via JMeter.
You can add i.e. Response Assertion to your test in order to introduce some pass/fail criteria, i.e. if you were in the middle of some transaction when the error occurred it should not finish successfully resulting in missing expected entry in the web page (or database), so you can conditionally fail relevant sampler(s) in this case. See How to Use JMeter Assertions in Three Easy Steps to learn more about the concept.
Alternatively you can use WebDriver Sampler plugin which provides JMeter integration with Selenium browser automation framework which drives a real browser, so you will be able to capture this popups and record the page titles/take screenshots, check out IsAlertPresent() class for more information.
you must get this error response in your jmeter request response.simple answer.Have a regex to extract.

invalidselector exception + selenium

I have been hit with InvalidSelectorException on a regular basis when i run my selenium web driver test script
My test fails with this InvalidSelector Exception and throws message as :
The xpath expression '//form[#name=somelocator]' cannot be evaluated or does not result in a WebElement
The element locator i use is perfect which return a correct web element when i cross verify it using xpath checker / or with browser console, so no issue with the element locator
I click on some button and then wait for the above xpath locator element to load in the application UI and giving enough waitTilllElementVisible() methods before checking the above locator
I found that many faced this issue, but could not get the concrete reason for this failure.
Selenium asks to visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html for the documentation on this error, but this link looks not up
Reproduced it with selenium 2.45 and 2.46 version with IE11
Please let me know if you knows the reason for this and why it throws invalidSelector exception on browser open with webdriver
I think the problem is the SPACE character in the #name tag. Try "//form[#name='some locator']" or '//form[#name=\'some locator\']'.
#peetya's answer is probably correct and a better answer but I prefer CSS Selectors... they are less error prone if you have the option to not use XPath.
driver.findElement(By.cssSelector("form[name='some locator']"));
CSS Selector reference

I get the same error on terminal for different file

I am running a feature file on Cucumber and every-time I get the same error message. No matter what feature file tags I run.
Missing Examples section for Scenario Outline at
features/support/internetonly.feature:10
(Cucumber::Core::Gherkin::ParseError)
Please help.
Thanks.
Error message speaks for itself: you have scenario outline without examples table. Either include examples table, either replace Scenario Outline: with just Scenario:.

When testing with WatiN: "'DebuggerDisplayProxy()' threw an exception of type 'System.InvalidCastException'"

FrameworkActionsLink = CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));
I have code which finds a link element by finding by ID.
The HTML on the page is:
<a id="actions" href="Javascript:ShowMenuItem('options','actions'); ... >
I have excluded the full Javascript code in the href where you see "...".
On test execution, sometimes this code works correctly, but sometimes I get the following error:
'DebuggerDisplayProxy()' threw an exception of type
'System.InvalidCastException'
It's a pretty straightforward bit of code, I just wondered if anyone had experienced similar problems or error messages. Do you think this is an issue with the WatiN tool, the web application, the internet browser, or perhaps something else entirely?
Can you try the following code:
FrameworkActionsLink = (WatiN.Core.Link)CurrentBuyerSite.BuyerWorkAreaFrame.Link(Find.ById("actions"));
I'm pretty sure that it doesn't like the link being JavaScript:...
Edit: Try maybe this:
CurrentBuyerSite.Eval("ShowMenuItem('options','actions'); ...");
What runner are you using? if nUnit 64bit then try 32bit or other runner.
Maybe the issue is that page didn't fully download and that makes problem with javascript function, try replace Click() for ClickNoWait().

Wicket.Ajax.Call.failure: Error while parsing response: Object required

I just spent several hours of my life debugging this problem. I'm documenting it here for others.
Question:
I'm getting the following error when I try to click on an AjaxLink in Internet Explorer:
Wicket: ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Object required
It works fine in all other browsers; just IE is busted.
Check to make sure that your HTML is 100% syntactically correct. Ajax responses are returned to the browser inside a CDATA section, and if the payload is not well-formed, IE will sometimes choke.
In my case I neglected to close a <link> tag in the <head> section. Simply closing that link tag made all the difference.
Aside: if you ever come across a tough-to-solve problem in Wicket, it's a good idea to create a quickstart project that reproduces your issue. It can be a lot of work to boil things down, but in doing so you often find the source of the problem.
I want to note one more potential reason for the issue with Wicket's AJAX in IE. It might help someone, who encounters similar problem.
In my case I had the following error message in IE:
Wicket: ERROR: Wicket.Ajax.Call.failure: Error while parsing response: could not find root <ajax-response> element
The reason was an incorrect Content-Type of AJAX response. I used AbstractTransformerBehavior and there was a bug in Wicket 1.4.x so this behavior was rewriting response Content-Type with text/html. IE does not parse such response as XML.

Resources