Hello
I sent out a previous message about having Selenium open firefox with
firefinder. Some how it was moved. I have an update and a question. Had
two guys trying to figure out what was going on. Anyway, as I develop my
Selenium scripts and run them and they fail I like to use
firefinder/firebug to view/check xpaths, etc. Now it is true that there
are some tools written for this purpose. They won't help me. Here's why.
A java program (testng) reads keywords and parameters from an excel file
like this:
TESTNAME input xpathKey value
and there are as many lines as is necessary for the test. *TESTNAME* is
the name of a specific test; *input* it a keyword (see below), *xpathKey *is
the xpath (see below) and *value *is the value to input into the xpath
which is an input box for instance.
*input* is a keyword which refers to a big switch statement. When input is
typed it matches a keyword which calls a method called *input() *and passes
*xpathKey *and *value *to it. This *input*() method does the actual
By.xpath (I forget the exact syntax), sendKeys(), etc, and returns "Pass"
or "Fail".
*xpathKey *is defined in a properties file (e.g., key=.//*[@id='tony']).
The method (e.g. *input*()) does a lookup in the properties file on
*xpathKey *and gets the actual xpath value. Note it does not have to be
named *xpathKey*. It could have any name like *inputNameTextBox,
deceasedCheckBox* (if keyword is *click* instead of *input*), or anything
valid.
*value *is defined in a second sheet in the execl file and could be any
valid value for the keyword, such as "George Washington", "123", etc. The
method (e.g. *input*() ) does a lookup on this definition.
What was happening is I would have an incorrect value for *xpathKey*. The
script would give an error and leave firefox open. But Selenium had opened
a barebones firefox with no firefinder so I could not debug. I would have
to manually open a firefox session, reset any data, and mimic what Selenium
did to get to a state where I could debug.
I found the following to have Selenium open firefox with firebug, which I
used:
Download the firebug xpi file from mozilla and start the profile as follows:
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1");
// Avoid startup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);
which wasn't working (I modified it for the version I had, which is newer).
The "Inspect Element with Firebug" was there but selecting it did not open
firebug. I asked someone for help and when I showed him how it was not
working, as you guess it worked and it opened up a firebug window. I
couldn't figure out why so I experimented and experimentd. Turns out, if I
tried to open firebug before the test had completed (Selenium was still
running) it would work. If I waited until the test finished before trying
to open firebug it would not work. If I opened firebug before the test
completed, closed firebug and let the test complete, firebug would open. I
can't figure out what is going on. I looked through the Selenium code to
see somehow whether the firefox profile was being changed but couldn't find
anything obvious. Right clicking on the firebug icon showed disabled at
the end of the test, but during the test sometimes showed disabled and
sometimes did not.
I suppose what I could do is set one breakpoint near the end of the test
and always run my scripts under debug. Then I think firebug might work,
but not if I let the test finish running it as normal testng. By the way,
by "finish" I mean come to an end. Even if the test hits an error (no such
xpath, element not clickable, etc) it will still return "Fail" and finish.
Any ideas what is going on?
--
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit
https://groups.google.com/d/msgid/firebug/b786ecaf-29a8-47b1-9394-c03b28ce3226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.