setCursorPosition not working in webdriver backed selenium

1,606 views
Skip to first unread message

robocop

unread,
May 15, 2012, 12:11:41 PM5/15/12
to seleniu...@googlegroups.com
Hi

Is there any reason why setCursorPosition not working in webdriver backed selenium . the code is

selenium.setCursorPosition("id=DATETO_0", "0");

and the source code of text box  is below

<input type="TEXT" onblur="TidyDate(" datefrom_0")"="" onfocus="CellFocus(" value="  /  /  " tabindex="0" maxlength="10" size="12" id="DATEFROM_0" name="DATEFROM_0" class="INPUT">

Thanks

Simon Stewart

unread,
May 15, 2012, 1:04:22 PM5/15/12
to seleniu...@googlegroups.com
It's because it's not implemented. Try breaking out the underlying
webdriver instance:

WebDriver driver = ((WrapsDriver) selenium).getWrappedDriver();
WebElement element = driver.findElement(By.id("DATETO_0"));
element.sendKeys(Keys.HOME);

Simon
> --
> You received this message because you are subscribed to the Google Groups
> "Selenium Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/selenium-users/-/Hkgwd5BJKhMJ.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to
> selenium-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/selenium-users?hl=en.

robocop

unread,
May 15, 2012, 1:17:53 PM5/15/12
to seleniu...@googlegroups.com
Hi Simon

I was thinking it might not be implemented. Good to know.

I will give this a bash, thanks for the quick response on this.

Richard


On Tuesday, May 15, 2012 6:04:22 PM UTC+1, Simon Stewart wrote:
It's because it's not implemented. Try breaking out the underlying
webdriver instance:

WebDriver driver = ((WrapsDriver) selenium).getWrappedDriver();
WebElement element = driver.findElement(By.id("DATETO_0"));
element.sendKeys(Keys.HOME);

Simon

On Tue, May 15, 2012 at 5:11 PM, robocop <richar...@gmail.com> wrote:
> Hi
>
> Is there any reason why setCursorPosition not working in webdriver backed
> selenium . the code is
>
> selenium.setCursorPosition("id=DATETO_0", "0");
>
> and the source code of text box  is below
>
> <input type="TEXT" onblur="TidyDate(" datefrom_0")"="" onfocus="CellFocus("
> value="  /  /  " tabindex="0" maxlength="10" size="12" id="DATEFROM_0"
> name="DATEFROM_0" class="INPUT">
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Selenium Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/selenium-users/-/Hkgwd5BJKhMJ.
> To post to this group, send email to selenium-users@googlegroups.com.
> To unsubscribe from this group, send email to
> selenium-users+unsubscribe@googlegroups.com.

Mark Collin

unread,
Feb 7, 2013, 7:53:51 AM2/7/13
to seleniu...@googlegroups.com
Looks convoluted, but transforming your code into the WebDriver API would make it look like:

Actions performAction = new Actions(driver);
WebElement myID = driver.findElement(By.id("myid"));
myID.sendKeys("mypage");
performAction.moveToElement(myID).perform();
myID.sendKeys("prank");


On 07/02/2013 10:33, Hub wrote:
What happens if we want to set the cursor position as we are doing in RC
selenium.type("id=myid","mypage");
selenium.setCursorPosition("id=myid",2);
selenium.type("id=myid","prank");

sothat the text in that box becomes myprankpage.How to implement this in webdriver...
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/DTC4z2A0f_QJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Message has been deleted
Message has been deleted

Mark Collin

unread,
Feb 8, 2013, 5:49:18 AM2/8/13
to seleniu...@googlegroups.com
Finding and creating a reference to an element is not the same as moving the mouse cursor over the element.

As I said in my original post it looks a bit convoluted, but I have just transformed the existing Selenium RC API code into its WebDriver API equivalent. I have no idea how valid the original code was.


On 07/02/2013 13:20, Bhargavan Marepalli wrote:

Actions performAction = new Actions(driver);
WebElement myID = driver.findElement(By.id("myid"));---finding the element
myID.sendKeys("mypage");                                    ----typing  "mypage"
performAction.moveToElement(myID).perform();        ---again moving to the same element 
myID.sendKeys("prank");                                        ---typing "prank"

In this case we are not really moving the cursor position to 2nd. is not it
Reply all
Reply to author
Forward
0 new messages