1

I am experimenting with the R port of Selenium, namely the recently released Relenium. Locating web elements on the page using Relenium seems straightforward enough so far. However, I am having difficulty selecting and deselecting checkboxes. Given the following code I would expect some change in the state of the checkbox on the web page:

library(relenium)
firefox <- firefoxClass$new()
firefox$get("http://jamaserv.jama.or.jp/newdb/eng/prod4/prod4TsMkEntry.html")
firefox$printHtml()

chkbox <- firefox$findElementByXPath("//input[@name='chkCarMaker4All'][@type='checkbox']")

chkbox$isSelected()
chkbox$click()
chkbox$isSelected()

What I get is this, which suggests that no change in state has been achieved:

chkbox$isSelected() # query checkbox state
[1] TRUE
> chkbox$click() # to deselect box
> chkbox$isSelected()
[1] TRUE # no change in state?
> 

I have looked at questions related to using Selenium in other languages such as this one for Java but haven't applied them to my own case with any success. This is the first time I have used Selenium, so it may be that I am missing something obvious in its Relenium variant. Any pointers on how to select/deselect checkboxes would be appreciated.

Community
  • 1
  • 1
SlowLearner
  • 7,907
  • 11
  • 49
  • 80

1 Answers1

0

It turns out that this is the result of some strange interaction between Firefox, Selenium and Windows 7.

If in your Windows 7 display settings the font is set to anything other than 100% then Selenium will not click on page elements. I had my fonts set to 125%. After resetting this to 100% I became able to set and unset checkboxes in Relenium, so it doesn't appear to be Relenium-specific after all.

The problem is mentioned in this Stack Overflow question and described in more detail and with a screenshot on this Selenium issue report page. Thanks to Relenium co-author Lluis Ramon for finding this fix.

Community
  • 1
  • 1
SlowLearner
  • 7,907
  • 11
  • 49
  • 80