SeleniumHQ / selenium-google-code-issue-archive

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

isElementPresent failing mysteriously... logs attached #7541

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 7541

Hi y'all,

  I'm seeing strange behavior and a selenium server error with no error message with
a call to isElementPresent.  Can you help figure out what is going on here?   Thanks!
 As far as I can tell, I'm on the latest versions of selenium and Firefox.  

  Thanks a lot!

  Dave

---------------

What steps will reproduce the problem?

1. Run selenium test on page.  

CALLING CONTEXT (see below for code of Wait::forElementPresent)

        $this->selenium->click("link=Click here to try it.");
        Wait::forElementPresent("//a[text()='Click to log in.']", $this->selenium, 30000,
"'Click to log in' link was not found.");

What is the expected output? What do you see instead?

There is a wait loop which waits for an element "//a[text()='Click to log in.']" that
is generated in once the page script is done running, but, after the selenium server
error (SEE LOG BELOW) is encountered, selenium exits immediately.  In other words selenium
isn't waiting as it should be.

Selenium version:  /usr/bin/java -jar /Users/dave/Downloads/selenium-server-standalone-2.42.2.jar
Java version:
  java version "1.6.0_65"
  Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
  Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

OS: Mac 10.9.3 (64bit)
Browser: Firefox
Browser version: 30.0
PHP version: 
  PHP 5.4.28 (cli) (built: May  7 2014 03:52:11) 
  Copyright (c) 1997-2014 The PHP Group
  Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
      with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
      with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
      with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo

Please provide any additional information below. 

---------------- HTML SRC OF PAGE BEING SCANNED
see attached: install_courseinsite.php

---------------- POSSIBLE HINT AS TO CAUSE?
see attached: character_encoding_issue_maybe? 

This was in the console window of Firefox when this was run.

---------------- PHP CODE CALLING CONTEXT
    /**
     * Waits for an element to be present in current page
     *
     * @static
     * @param type $locator selenium element locator
     * @param type $selenium reference to calling selenium instance
     * @param type $timeout time out value in seconds (default 60)
     * @param type $failureMessage override default message to dispaly on timeout
     */
    static function forElementPresent( $locator, $selenium, $timeout= SE_TIMEOUT_SECONDS,
        $failureMessage = 'failed due to timeout' ) {
        for ( $seconds = 0;; $seconds++ ) {
            if ( $seconds >= $timeout ) {
print(__FUNCTION__." :: --- TIMED OUT while waiting for { $locator } to load ---\n");
                throw new PHPUnit_Framework_AssertionFailedError(__FUNCTION__." :: $failureMessage"
);
            }
            try {
              $present = $selenium->isElementPresent( $locator );
              // print("\npresent: ".gettype($present)." = ".(int)$present );
            if ( $present ) {
              //print("FOUND ITEM\n");
                break;
            }
            } catch (PHPUnit_Framework_AssertionFailedError $e) {
print(__FUNCTION__." :: COULD NOT FIND SELECTOR { $locator }");
                throw new PHPUnit_Framework_AssertionFailedError(__FUNCTION__." :: COULD NOT FIND
SELECTOR { $locator }\n".$e->toString());
            }
            sleep( 1 );
        }
    }

----------------- SELENIUM SERVER LOG (full session, error is near the bottom)

16:21:05.023 INFO - Command request: getNewBrowserSession[*firefox /Applications/Firefox
v30.0.app/Contents/MacOS/firefox, http://localhost/] on session null
16:21:05.023 INFO - creating new remote session
16:21:05.023 INFO - Allocated session b8705a6bc8e74e598b16eec0ebcc42a8 for http://localhost/,
launching...
jar:file:/Users/dave/Downloads/selenium-server-standalone-2.42.2.jar!/customProfileDirCUSTFFCHROME
16:21:05.053 INFO - Preparing Firefox profile...
16:21:10.342 INFO - Launching Firefox...
16:21:14.140 INFO - Got result: OK,b8705a6bc8e74e598b16eec0ebcc42a8 on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:14.150 INFO - Command request: setTimeout[50000000, ] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:14.182 INFO - Got result: OK on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:14.188 INFO - Command request: getExpression[install_courseinsite.php, ] on session
b8705a6bc8e74e598b16eec0ebcc42a8
16:21:14.198 INFO - Got result: OK,install_courseinsite.php on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:14.201 INFO - Command request: open[install_courseinsite.php, ] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.312 INFO - Got result: OK on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.652 INFO - Command request: getExpression[exact:WARNING! I will delete each
table before installing it!, ] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.656 INFO - Got result: OK,exact:WARNING! I will delete each table before installing
it! on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.658 INFO - Command request: isTextPresent[exact:WARNING! I will delete each
table before installing it!, ] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.664 INFO - Got result: OK,true on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.677 INFO - Command request: getExpression[link=Click here to try it., ] on
session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.680 INFO - Got result: OK,link=Click here to try it. on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.692 INFO - Command request: click[link=Click here to try it., ] on session
b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.698 INFO - Got result: OK on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.718 INFO - Command request: getExpression[//a[text()='Click to log in.'],
] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.724 INFO - Got result: OK,//a[text()='Click to log in.'] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.754 INFO - Command request: isElementPresent[//a[text()='Click to log in.'],
] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:18.760 INFO - Got result: OK,false on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:19.763 INFO - Command request: getExpression[//a[text()='Click to log in.'],
] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:20.122 INFO - Got result: OK,//a[text()='Click to log in.'] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:20.124 INFO - Command request: isElementPresent[//a[text()='Click to log in.'],
] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:20.129 INFO - Got result: ERROR: Command execution failure. Please search the
user group at https://groups.google.com/forum/#!forum/selenium-users for error details
from the log window.  The error message is:  on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:20.131 INFO - Command request: testComplete[, ] on session b8705a6bc8e74e598b16eec0ebcc42a8
16:21:20.132 INFO - Killing Firefox...
16:21:20.354 INFO - Got result: OK on session b8705a6bc8e74e598b16eec0ebcc42a8

Reported by supertwang on 2014-06-25 21:51:09


lukeis commented 8 years ago
Can't reproduce with the attached page.

    DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost/");
    selenium.start();
    try {
      selenium.open("http://localhost/install_courseinsite.html");
      selenium.isElementPresent("//a[text()='Click to log in.']");
      Thread.sleep(5000);
    } finally {
      selenium.stop();
    }

Log:

02:06:43.614 INFO - Command request: getNewBrowserSession[*firefox, http://localhost/,
] on session null
02:06:43.616 INFO - creating new remote session
02:06:43.643 INFO - Allocated session 00c55248eb3f4857a97bac322cda586b for http://localhost/,
launching...
jar:file:/C:/Devel/selenium/build/dist/selenium-server-standalone-2.42.2.jar!/customProfileDirCUSTFFCHROME
02:06:43.769 INFO - Preparing Firefox profile...
02:06:46.070 INFO - Launching Firefox...
02:06:49.977 INFO - Got result: OK,00c55248eb3f4857a97bac322cda586b on session 00c55248eb3f4857a97bac322cda586b
02:06:49.980 INFO - Command request: open[http://localhost/install_courseinsite.html,
] on session 00c55248eb3f4857a97ba
c322cda586b
02:06:50.157 INFO - Got result: OK on session 00c55248eb3f4857a97bac322cda586b
02:06:50.159 INFO - Command request: isElementPresent[//a[text()='Click to log in.'],
] on session 00c55248eb3f4857a97ba
c322cda586b
02:06:50.193 INFO - Got result: OK,true on session 00c55248eb3f4857a97bac322cda586b
02:06:55.197 INFO - Command request: testComplete[, ] on session 00c55248eb3f4857a97bac322cda586b
02:06:55.197 INFO - Killing Firefox...
02:06:55.282 INFO - Got result: OK on session 00c55248eb3f4857a97bac322cda586b

Reported by barancev on 2014-06-25 22:09:50

lukeis commented 8 years ago
Closing the issue as it is not reproduced.

Reported by barancev on 2014-07-27 10:13:33

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:22:40