Selenium writing on two different text boxes for the same sendKeys() - selenium

I have an issue where selenium sendKeys(String) method, writes half the string on a text box, then complete the rest of the string in a different text box.
I don't know how is this possible, I think it might be an issue with the selenium driver itself (am using chrome driver 2.13). Any idea about a root cause for this.Note that the code worked fine for a long time.
regards

Related

How to copy all content in a webpage using selenium in headless mode?

Below I describe the issue I need help with.
Description
I wan't to simple copy content from URL: https://www.di.se/bors/large-cap/ to my Windows clipboard. I scroll down a bit on webpage (to get all content) and mark all before copy.
I want to this in selenium headless mode.
Problem
When I scroll down a little on the page and mark all and then copy the content, the clipboard does not contain the content I copied in headless mode in selenium. Important to know that this working as expected in normal selenium mode.
I have tried with three different browsers: Chrome, Edge and with Firefox. I have also tried with different ways to make the nessecary key strokes (sendKey, Actions and with the Robot class). See code example of the different ways below. Regardles what I'm doing the content is never copied to the clipboard.
Examples:
((JavascriptExecutor) driver).executeScript("scroll(0,400)");
driver.findElement(By.cssSelector("body")).sendKeys(Keys.chord(Keys.CONTROL, "a"));
driver.findElement(By.cssSelector("body")).sendKeys(Keys.chord(Keys.CONTROL, "c"));
Actions builder = new Actions(driver);
Action selectAll=builder.keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL).build();
Action copy=builder.keyDown(Keys.CONTROL).sendKeys("c").keyUp(Keys.CONTROL).build();
selectAll.perform();
copy.perform();
iRobot.keyPress(KeyEvent.VK_CONTROL);
iRobot.keyPress(KeyEvent.VK_A);
iRobot.keyRelease(KeyEvent.VK_A);
iRobot.keyRelease(KeyEvent.VK_CONTROL);
iRobot.keyPress(KeyEvent.VK_CONTROL);
iRobot.keyPress(KeyEvent.VK_C);
iRobot.keyRelease(KeyEvent.VK_C);
iRobot.keyRelease(KeyEvent.VK_CONTROL);
Question
Is there a way to copy the content to clipboard or can some workaround help?
From what I can find, it seems there is no way to access the clipboard in headless mode. I can't find anything definitive but this is as close as I can get to proof that it can't be done: https://groups.google.com/g/selenium-users/c/-nxTX4eTbwA/m/wQY_HlZQBAAJ

How to record test cases with robotframework?

I recently started using robotframework with the Selenium2Library. I haven't tested using Selenium before, but I know it is possible to record tests using Selenium. In RobotFramework, it says, "it is not possible". I mean even for a simple login test, I need to write the test, specifying the id of username, password and submit button.
However, is there any way by which these tests can be recorded using robotframework? such as clicking on a text box, entering a string and then clicking on submit button etc., and automatically generate the test case source code instead of having me to write the test cases. Is this possible with robotframework or any external library that it supports?
robotframework wasn't designed to be a record-and-play tool, and has nothing built-in to support that.
There was someone who wrote a selenium IDE plugin that would generate robot keywords, but that was years ago. The github repository is here: https://github.com/denschu/selenium-ide-format-robotframework
The code hasn't been touched since 2012, so I doubt it's of much use.
Using this Firefox add-on, FireRobot we can generate most of the code and also using this you can select the elements on the screen and get related code suggestions on right click like
Wait Until Element Is Visible
Click Element
and all operations to perform on the selected element.

Selenium IDE click and drag

I am using the Selenium IDE extension for testing webpages in FireFox and I was able to find out how to perform almost every command that I need to automate testing for my webpage.
Unfortunately I was not able to find out how to do this through the list of commands that you can manually enter into the queue of Selenium IDE.
I was wondering if anyone knew how to do this in the Firefox extension. Thanks!
You can use dragAndDropToObject command which locates the target element and drags it to the centre of the destination element.
dragAndDropToObject
target: locator of the element to drag
value: locator of the destination element
There is also a dragAndDrop command which drags the element by specified amount of pixels and drop it.
For one thing, you might want to use Selenium Builder instead of Selenium IDE. Also, there are some things that Builder or IDE cannot record, such as iFrame interactions, certain AJAX actions, and also drag and drops. For those, you need to code them by hand afterwards and get them working.

Selenium IDE skips certain fields

I'm using Selenium IDE to test our website/application. I have noticed that there are specific fields on which Selenium gets stuck. At any test speed, when Selenium gets to that field in the testing it gives out the error that it cannot find the ID. But then I double click on the test line it then goes through. In other words, Selenium IDE can find the ID when I double click on the test line, but not when it is automatic.
Moreover, it is always with the same specific fields. 95% it finds, but a few it gets stuck on in automatic mode.
Also, something similar. I have a specific page where you type data into a series of textboxes. For those specific textboxes it always skips a few of them when in automatic mode. No problem when I double click it. Only when automatic. But all other textboses are fine.
And this occurs even at the slowest speed.
Thank you.

Why are Selenium IDE playback controls inactive? (How can I run recorded tests?)

I started learning how to use Selenium today. I have never used it before. I downloaded the Selenium IDE (1.0.10) plugin for FireFox (3.5.16). The way it's behaving is not matching up to the docs.
When I click the record button and perform actions in my browser, nothing happens in the IDE (nothing is recorded). (Actually, initially it did record, but now it doesn't) I tried restarting FireFox and that had no effect.
Also, the main controls are now inactive. I've included a screen shot to show what I mean by that. The controls remain inactive even it I click or double click on the name of a test case in the panel on the left.
And one final question -- it appears that a Selenium test case mentions Chrome in its default configuration even though the docs say you can only record tests using FireFox. Should I do anything about that?
If anyone can shed light on any of the above mysteries I would appreciate it. Thanks!
UPDATE
I restarted FireFox again and now it's recording actions, but the controls are still greyed-out as in the screenshot, so I can't play back the test.
The issue is that you are not in the HTML runner mode. The IDE has no concept of ruby or python or c# or Java. That is up to plugins which just essentially do a find an replace.
*chrome means Firefox Chrome. Something that has been around for a lot longer than Google Chrome the browser. It means use the browser chrome which removes a couple sandboxing issues.
If you want to play back the tests you can't go out of the table mode otherwise the IDE won't understand what to do. The code in the screenshot should be stored in a .rb file and that should be executed.
Let me try to unravel mysteries -
As soon as you launch the IDE it would be in recording mode. Do you see last Red button which is enabled.
IDE Tests can be executed only when in the selenese/html format (aka table format). I guess you have changed the format to ruby (I guess so), from Option > Format.
To be able to execute tests change it back to html from option > Format > HTML
Take my words, IDE is only and only for firefox