SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

XPath Fails to Resolve in Firefox, but only when PC is connected to a projector #2561

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 2561

Selenium version:  Dotnet 2.7.0
OS:  Windows 7
Browser:  Firefox
Brower version:  3.6.6
Language:  C#
Compiler:  VS 2010

I'm having a very strange problem with the Firefox webdriver.  I have a test that performs
several actions on a Drupal-based page (I'm sorry but I'm prohibited from sharing the
HTML code).  Everything works perfectly on Firefox, IE, and Chrome when performed on
my laptop.

But here's where it gets weird:  When I hook my laptop into the projector (which seems
to alter the screen resolution and mirrors what's being displayed on the monitor; i.e.
it's not a "multi-monitor" type setup), Firefox is suddenly unable to retrieve the
XPath for one of the buttons.  However, Chrome and IE still handle it perfectly, and
Firefox also works up until that button click.  It doesn't throw an exception; it just
fails to click the button.  However, if I disconnect the laptop from the projector
and immediately run the test again on Firefox, it works perfectly.

I've tried maximizing the browser before the test begins, but that doesn't affect the
error.  I haven't tested this in a newer version of Firefox yet.

I wish I could give you some source code to look at but I'm contractually prohibited
from doing so.  This seems like a bug either in the FirefoxDriver or just Firefox itself.
 But either way, I'm still pretty new to this so I'm hoping one of you might be able
to tell me if this is a bug or if you can think of anything that would cause Firefox
to flub like this when connected to a projector (VGA output).

Steps to Repro:

1. Connect laptop to projector.
2. Attempt to click a button with an XPath of:  //form[@id\='omn-push-form']/div/div/table[2]/tbody/tr[8]/td[2]/div[2]/div/input
 (again, I'm not permitted to include the HTML source)
3. The button won't click and no exception will be thrown.
4. Try the same thing in IE and Chrome.  Both will have no trouble with it.
5. Disconnect from the projector.
6. Repeat the test in all browsers.  All of them, including Firefox, will now be able
to click the button without any changes to the HTML source or the test parameters.

Reported by kris.craig on 2011-09-29 17:07:19

lukeis commented 8 years ago
Oh and btw, the "\=" in the XPath should be replaced with "=".  The \ is just an escape
character that I forgot to remove before posting, sorry.

Reported by kris.craig on 2011-09-29 17:09:17

lukeis commented 8 years ago
Can you try turning off native events? 

In Java that would be something like:

  FirefoxProfile profile = new FirefoxProfile()
  profile.setEnableNativeEvents(false);

  WebDriver driver = new FirefoxDriver(profile);

Since it's affected by screen resolution, I'm guessing it's a native events issue.

Reported by jari.bakken on 2011-09-29 23:18:20

lukeis commented 8 years ago
Is there a certain assembly reference I need to add for setEnableNativeEvents?  It's
throwing an error:

Error   4   'OpenQA.Selenium.Firefox.FirefoxProfile' does not contain a definition for
'setEnableNativeEvents' and no extension method 'setEnableNativeEvents' accepting a
first argument of type 'OpenQA.Selenium.Firefox.FirefoxProfile' could be found (are
you missing a using directive or an assembly reference?)

Reported by kris.craig on 2011-09-30 00:29:07

lukeis commented 8 years ago
Btw I tried Googling it and looking in WebDriver.chm but couldn't find any information
on where to access it from.

Reported by kris.craig on 2011-09-30 00:30:15

lukeis commented 8 years ago
Jim, can you help with the .Net equivalent here?

Reported by jari.bakken on 2011-09-30 08:02:15

lukeis commented 8 years ago
It should be:

 profile.EnableNativeEvents = false;

This property should be fully documented in the FirefoxProfile class in both the online
API docs and the .chm included in the download.

Reported by james.h.evans.jr on 2011-09-30 11:41:39

lukeis commented 8 years ago
In case my last comment got emailed before I deleted it, please disregard.  I realized
I'd forgotten to pass the profile variable to the driver class.  I corrected it and
will post the results here in a few minutes.

Reported by kris.craig on 2011-09-30 22:12:16

lukeis commented 8 years ago
Mixed results.  The original issue was fixed, but at the cost of introducing a new issue.
 When the EnableNativeEvents flag is set to false, Firefox fails to click on a checkbox
(located via FindElement By.Id).  It doesn't hang, however; it just skips past it entirely.
 This happens even when I'm not connected to the projector!

If I set EnableNativeEvents back to true and run the same identical test again (not
connected to the projector), the test runs fine, including clicking the check box.

Any thoughts on why setting EnableNativeEvents to false would cause this to happen?
 And could anyone suggest something that will fix that without reintroducing the projector
issue?  I could just try looking by XPath instead, but the app I'm developing is designed
for QA personnel with zero development experience, so I need to keep this as simple
and with as few confusing quirks as possible.

Thanks for all your help thus far!

Reported by kris.craig on 2011-09-30 22:24:13

lukeis commented 8 years ago
I just tried doing it by XPath:  //div[@id\='edit-hipaa-wrapper']/label

Same issue.  Run normally, it clicks the checkbox just fine.  Run with EnableNativeEvents
= false, it skips right past it.

Reported by kris.craig on 2011-09-30 23:03:49

lukeis commented 8 years ago
I'm closing this issue as WontFix as there is no known way to reproduce it.

Feel free to reopen it if you have additional details that could help us to fix it
properly.

Reported by barancev on 2012-06-03 14:12:00

lukeis commented 8 years ago
I can't re-open it because I don't have access.

This CAN be reproduced.  You just need to have a laptop with an external VGA port for
dual-display.  Why, exactly, would you say that "there is no known way to reproduce
it" when this can EASILY be reproduced?!

Would somebody please re-open this?  I'm not sure what @barancev was thinking, but
this bug is reproducable and I clearly outlined how to do this in the original post.

If you don't want to fix it because you just don't think it's a priority, then please
say so.  But don't cite false reasons for closing it; that's very disrespectful to
the person who went to the trouble (i.e. me) of filing the bug in the first place.

PLEASE RE-OPEN THIS BUG ASAP!  Thank you.

Reported by kris.craig on 2012-06-03 21:52:21

lukeis commented 8 years ago
And if it's not re-opened, then at least let the record show that the OP (me) **STRONGLY**
objects to the closure of this bug due to the deceptive reason cited for closing it.

Reported by kris.craig on 2012-06-03 21:54:52

lukeis commented 8 years ago
In case barancev was confused about the repro steps, the ID doesn't have to be an exact
match (in fact it won't be).  It just has to be any text input field on any dev-generated
Drupal form.

Reported by kris.craig on 2012-06-03 22:03:19

lukeis commented 8 years ago
I'm a professional trainer, and I do selenium workshops on the regular basis. I use
projector to demonstrate Selenium all the time, and I've never seen this issue. Dual-mode,
extended display, projector only -- no problem.

I can claim for sure that it is not a *common* projector-related issue.

It is either related to your page structure, or your environment (zoom level, screen
resolution, etc).

I'm reopening the issue, and request you again to provide a reproducible test case.

Please create a sample page that demonstrates the issue and can be shared with us.
Or find a page on a public site that can be used to reproduce the issue.

Reported by barancev on 2012-06-04 07:24:48

lukeis commented 8 years ago
@barancev Did you do your testing in Drupal 6.22 on dev-generated forms (in PHP created
using the $forms array)?

This is generic Drupal stuff.  The form has specific content/labels but the core is
unmodified.  You should be able to repro this on any Drupal 6.22 form.

Either way, it would not be appropriate to close the bug based solely on "past experience,"
regardless of how "vast" that experience may be.  I've been using Selenium for QA since
I worked at Microsoft and was in charge of validating all new Windows builds of PHP
release candidates.  I wouldn't have reported this issue without first ruling out other
potential non-Selenium factors.

So please, regardless of any anecdotal past experiences, install Drupal 6.22 and configure
a basic form, then repro this issue replacing my ids (i.e. "omn-push-form") with your
own.  Like I said, this should be easy to reproduce if you have a suitable dev environment.

If you attempt to repro the bug, please post your results and the form conditions here
regardless of whether you were successful or not.  If you fail to reproduce it, I should
be able to take what you did and narrow down what might've been different.  But unless/until
we reach a point where we simply cannot repro this, or it's decided that the issue
simply isn't "worth" fixing, IMHO this bug should remain open.  I'll do whatever I
can to assist you in being able to reproduce this in your dev environment.

Reported by kris.craig on 2012-06-04 07:36:03

lukeis commented 8 years ago
Issue 4021 has been merged into this issue.

Reported by barancev on 2012-06-04 07:45:57

lukeis commented 8 years ago
Dear sir, I'm not a drupal developer and I can't create a drupal-based site in a munute.

So I've tried a public drupal demo site first:

FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.danetsoft.com/demo/contact");
driver.findElement(By.id("edit-name")).sendKeys("tester");
driver.findElement(By.id("edit-mail")).sendKeys("tester@test.com");
driver.findElement(By.id("edit-subject")).sendKeys("test subject");
driver.findElement(By.id("edit-message")).sendKeys("test message");
driver.findElement(By.id("edit-submit")).click();

This piece of code works with projector as well as without it.

Is this a representative sample?

Can you please try it to check if it works in your environment?

Reported by barancev on 2012-06-04 08:17:52

lukeis commented 8 years ago
I can't blame ya there.  Personally, I hate Drupal.  But it's widely used so I have
to support it.  :/

Unfortunately, that's not a representative sample.  Because the module we're using
creates randomized ids for form fields (see "I hate Drupal" above), it has to go by
the XPath.  Also, what version of Firefox are you using?  Is it current?  Last I tested
this was back in September and it was only the Firefox driver that was breaking, so
maybe if we're super-lucky it could be a browser bug that has since been fixed (*fingers
crossed*).  But we'll still need to confirm that of course lol.

Also, could you provide the HTML source?  I tried the URL you included but it returned
a Drupal 404 template.

If you try it via XPath and it still works, I should be able to narrow down something
specific in the HTML source that's causing Firefox to vomit. 

Reported by kris.craig on 2012-06-04 18:23:13

lukeis commented 8 years ago
@kris

Please can you attach a test case (a C# File) against a site that we can access so
that this issue can be resolved. Anything short of this is just going to have a lot
of back and forth.

Reported by david.burns@theautomatedtester.co.uk on 2012-06-04 18:53:01

lukeis commented 8 years ago
Here is the URL I've used in the code: http://www.danetsoft.com/demo/contact

I've tried Firefox versions 3.6.28, 10esr, 12.
I've tried to access the elements by ID, by XPath, by CSS -- all works as expected.

Let's try to attack the problem from the opposite side -- can you provide the code
of the page where you can reproduce the issue? Please create a copy of the page in
MAFF format [1] and attach it here.

[1] https://addons.mozilla.org/ru/firefox/addon/mozilla-archive-format/

Reported by barancev on 2012-06-04 18:54:41

lukeis commented 8 years ago
I have to be very careful about this because it's proprietary software and the company
is very protective on that front.  I'd probably have to write something new and give
you that, otherwise I'd be in breach of contract.  Let me give it some thought though
and see what I can do.

Reported by kris.craig on 2012-06-04 19:02:23

lukeis commented 8 years ago
I don't see what we can do to fix this issue. The only way to fix it is debugging in
the faulty environment, that seems to be very unique. I'm closing it, sorry.

Reported by barancev on 2013-02-24 19:55:51

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:13:47