Attribute Error: On selenium-python script - selenium

I am using Selenium-python script for web test automation. When ever I use selenium inbuilt commands, I will get Attribute error during run time.
Ex: selenium.WindowFocus("preview_email") throws "AttributeError: class selenium has no attribute 'WindowFocus'"
I am new to test automation. Help me to sort out this problem.

The command that you are looking for is selenium.window_focus()

I have never used the Python client personally, but a quick glance at the selenium.py file reveals that there is a window_focus command which gives the currently "selected" window focus ("selected" in Selenium terms is the window that Selenium is currently executing commands against and not necessarially the window that has user focus).
Executing the select_window command with a window ID will set tell Selenium which window you want to execute commands against.
I have had some trouble w/ popups in general and the way the Selenium IDE and RC clients attempt to locate new windows and/or there parents. Good luck.

I think you want to force web-driver to go to another window with name "preview_email".
For this purpose, you need to use selenium.switch_to_window("preview_email"); because selenium.window_focus() just gives focus to the currently selected window and accepts no arguments. Additionally you used it in JAVA mode (I mean selenium.windowFocus()).

Related

Selenium IDE Test Runs in GUI - But Fails when run in CL (linkText not Visible)

When my saved project and test runs in the Selenium IDE GUI it's fine, but when I perform the same test called via the command line side runner it fails. The issue appears to be the linkText not being visible, but I don't understand why it would fail when it runs fine form the GUI.
You can see the last step (8) as passed, with reference to the linkText
I then save the project in my local folder
And run it again using the side runner command
ElementClickInterceptedError: element click intercepted: Element Corporate Project/Program/Event (CORP) is not clickable at point (798, 199). Other element would receive the click: ...
It appears that the linkText maybe covered? The weird thing it's visible to me when the selenium test is running, just before it hangs. I did try to add some wait commands, i.e. "wait for element visible". But didn't seem to help.
Maybe I didn't insert the command properly?
I feel like I must be missing something obvious. Any suggestions?
I've found similar threads on GitHub that indicate differences in the way the IDE core and web driver work. One user indicates it actually IDE that's clicking through an overlay. I've managed to overcome my issues using simple pause commands, unsure why the wait commands didn't work for me.

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 Custom error messages

I have read this (How to customize Selenium test error/fail message) question and it gave me some hope but can this be done with selenium IDE also? My boss wants to automate all tests but wants to keep it simple for non programmers to use so I cannot use WebDriver or jUnit.
I had a similar issue and came out with a surprisingly amusing answer. Selenium will write a failure only upon stepping on an error. In the current case I wanted Selenium to warn me if the 'Log In' button was absent on my page but a gotoIf wasn't going to do the job alone. Therefore I forced Selenium into an error by writing a click command that didn't exist 'TestLoginB2B failed because the login button was' and using it as my custom error line as Selenium will mention the name of a failed click command and always write them in red therefore allowing my file logging addon to spot them.
Custom error message

Selenium IDE down arrow key

I'm stuck trying to get my selenium testing to simulate a down arrow key press.
Im just using the html format for my tests and am using typeKeys as the command, the target is correctly found, and for the value I am putting in \40 which seems to be converted into \\40 in the UI. When I run the command it ends up appending \40 to the current value of the input.
I'm using the latest version of the selenium ide from the site.
Any pointers?
Cheers
Selenium provides its own methods for this task.
Try using keyDown() instead of typeKeys()

Selenium: How to stop RemoteRunner.html from getting invoked

I am using selenium for one for my Java applications on linux. The application invokes a mozilla browser, fills login details (username and password), and then submits the form. I am able to achieve this using selenium, but every time a url is selected 2 instances of mozilla is getting invoked. One instance is that of the url selected and the other instance is a RemoteRunner.html which has selenium command history and other details.
I don't want this page to be invoked. Is there a way to stop this page from getting invoked?
Thanks and Regards,
Sunil.
The RemoteRunner window is required as it is controlling the application under test within the other window. You can run Selenium in a single window using the command line option multiWindow=false however this uses frames, which can sometimes cause issues with the application under test.