SeleniumHQ / selenium-google-code-issue-archive

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

Unable to click on checkbox element in IE7 #2857

Open lukeis opened 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 2857

Hello all,

It looks like checkbox in IE7 is ignored altogether in IE7 test runs where it is being
picked up by Firefox (using 6.0 for my tests at least).

What steps will reproduce the problem?
This testcase is a travel room booking experience.

1. Go to https://qaone.v112test.ezrez.com/travel/arc_waiting.cfm?origin=%2Ftravel%2Farc.cfm%3Ftab%3Dr&room1=true&area2_display=HNL&area2=HNL&date1=12%2F28%2F11&date2=12%2F29%2F11&num_rooms=1&adults=1&child_age1=-1&child_age2=-1&child_age3=-1
2. Select 'ROOM TEST HOTEL ONE DO NOT CHANGE PRODUCTION DATA' room (4th one down from
top)
3. Click on first 'add to booking' button'
4. Click continue button
5. Again, Click continue button
6. On 'Please enter payment details' page, there is a check box named 'I agree'. 

NOTE: This is the checkbox mentioned above which is problematic to IE7 and not FF 6.

What is the expected output? 
- The expected output is the click to 'continue' button on to the next page successfully
to complete this booking.

What do you see instead?
- I get an exception..

Cannot click on element (WARNING: The server did not provide any stacktrace information);
duration or timeout: 141 milliseconds Build info: version: '2.8.0', revision: '14056',
time: '2011-10-06 12:41:26' System info: os.name: 'Windows XP', os.arch: 'x86', os.version:
'5.1', java.version: '1.6.0_27' Driver info: driver.version: RemoteWebDriver; duration
or timeout: 832 milliseconds Build info: version: '2.8.0', revision: '14056', time:
'2011-10-06 15:53:48' System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.18-274.3.1.el5',
java.version: '1.6.0_24' Driver info: driver.version: RemoteWebDriver
Stacktrace

org.openqa.selenium.ElementNotVisibleException: Cannot click on element (WARNING: The
server did not provide any stacktrace information); duration or timeout: 141 milliseconds
Build info: version: '2.8.0', revision: '14056', time: '2011-10-06 12:41:26'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version:
'1.6.0_27'
Driver info: driver.version: RemoteWebDriver; duration or timeout: 832 milliseconds
Build info: version: '2.8.0', revision: '14056', time: '2011-10-06 15:53:48'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.18-274.3.1.el5', java.version:
'1.6.0_24'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:415)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:232)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:73)
    at com.ezrez.automation.component.BasePage.click(BasePage.java:70)
    at com.ezrez.automation.component.booking.PaymentDetails.checkAgreeToTerms(PaymentDetails.java:60)
    at com.ezrez.automation.component.booking.PaymentDetails.payByCreditCard(PaymentDetails.java:76)
    at com.ezrez.automation.test.room.InternalRoomCancelIT.scenario(InternalRoomCancelIT.java:38)
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
Build info: version: '2.8.0', revision: '14056', time: '2011-10-06 15:53:48'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.18-274.3.1.el5', java.version:
'1.6.0_24'
Driver info: driver.version: RemoteWebDriver

Selenium version: 2.8.0
OS: Windows 2003
Browser: IE 7

Here's how selenium interacts with this element:
webDriver.findElement(By.cssSelector(".termsInput")).click();

Reported by atiq.rahman on 2011-11-16 19:47:23

lukeis commented 8 years ago
Try to wait for the element to become visible before click:

WebElement iagree = new WebDriverWait(driver, 10).until(
    ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".termsInput")));
iagree.click();

Reported by barancev on 2011-11-16 20:58:30

lukeis commented 8 years ago

Reported by barancev on 2011-11-16 20:58:51

lukeis commented 8 years ago
Thanks for your tip. Unfortunately, I am still getting the same error with the same
stack trace.

Reported by atiq.rahman on 2011-11-17 00:25:29

lukeis commented 8 years ago
OK, reproduced on WinXP with IE7. At the same time, IE9 on Win7 works as expected. Need
to check other IE versions.

Repro scenario:

import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;

import junit.framework.Assert;

import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.SeleneseCommandExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;

import com.opera.core.systems.OperaDriver;

public class Bug2857 {

  public static void main(String[] args) throws Exception {
    WebDriver driver = new InternetExplorerDriver();
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    driver.get("https://qaone.v112test.ezrez.com/travel/arc_waiting.cfm?origin=%2Ftravel%2Farc.cfm%3Ftab%3Dr&room1=true&area2_display=HNL&area2=HNL&date1=12%2F28%2F11&date2=12%2F29%2F11&num_rooms=1&adults=1&child_age1=-1&child_age2=-1&child_age3=-1");
    List<WebElement> hotels = driver.findElements(By.className("hotelOption"));
    hotels.get(4).findElement(By.className("card_link")).findElement(By.tagName("a")).click();
    driver.findElement(By.className("roomPrice")).findElement(By.className("submit_link")).findElement(By.tagName("a")).click();
    driver.findElement(By.className("submit_link")).click();
    driver.findElement(By.className("submit_link")).click();
    WebElement iagree = driver.findElement(By.cssSelector(".termsInput"));
    Assert.assertFalse(iagree.isSelected());
    iagree.click();
    Assert.assertTrue(iagree.isSelected());
  }
}

Reported by barancev on 2011-11-17 07:53:03

lukeis commented 8 years ago
Sorry for getting back so late since I was out on vacation...Anyways, thanks for the
code solution above but for some reason it did not work for me.

However, what did work for me was the JavascriptExecutor work around below just before
the click(). This work like a magic.

((JavascriptExecutor) webDriver).executeScript("window.scrollTo(0,document.body.scrollHeight);");

Reported by atiq.rahman on 2011-12-08 23:11:31

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 17:44:26