I am currently working on a project which has few Id's in the first screen and depending on the Id selected, user is navigated to second page which displays respective Id's information. All the information displayed is retrieved from SQL database.
Here is my question how can I automate this using Selenium.
Thanks in advance
If you have a coding background I would suggest writing some basic automated tests with Selenium WebDriver. This will allow you to find elements on the page via their ids, get text from textfields, click on links, and verify that another page has loaded (sounds like the tasks you wish to perform?). You can structure your tests so they run through the main functionality path (eg. go from log in, to main screen, to another screen, testing all functionality along the way) and then you will only have to write a few tests. If you want full automation it is usually better to have specific requirements for your application and write a separate test for each. The Selenium homepage has some good documentation with code snippets to get you started, and a simple google search should provide you with several tutorials. Good luck :)
Related
I am working on automating an inhouse automation testing software for my firm, I need to extract the X-path, or id of an HTML element when the tester clicks the webpage element like the login button during the manual testing process, need to extract data like element id or x-path, and what type of action he is performing like click, enter or filling the text box, etc. these data would be useful for integrating with my existing selenium script and perform automation testing, currently exploring feasibilities of computer vision. Kindly suggest some ideas to make it possible.
-I think you need to extract and read HTML of the page separately then perform any concept/Algorithm of computer vision to detect all elements of the page including text , buttons and drop down list....
During automating a website after navigating several pages I reach a page where I cannot perform any action using Selenium. Even when I try to get current title or current URL, I get the stuff from very previous page and if I do some random click anywhere on page it happens on the previous page.
In short this particular page cannot be automated or It does not have driver to perform action(driver remains on the previous page). So I want to know Is it possible that a particular page cannot be automated using selenium or a particular property that is set to prohibit doing automation.
If NO then how can I handle such situation? How can I make driver to work on current page.
From your comments, the new page is actually in the new browser window. Reading the documentation might be helpful. Here's another stackoverflow question that could help you too.
The general idea would be to use (in python) the driver.window_handles property to keep track of browser windows before and after the new window opens, then driver.switch_to_window(new_browser) so that subsequent actions point to the new browser.
Don't forget to use driver.switch_to_window() to get back to the original when you need to.
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.
Hi ive developed a application that works with my site by using
SendKeys.send("{ENTER}") to submit info on one of my forms.
Is there a way to stop it from running outside the application?
For example im trying to run the program in the background and when im browsing my facebook or on google it randomly keeps hitting enter.
Any help is greatly appreciated thanks for your time.
The short answer is to look at the windows available for a process and check the titles to see if it's the page you want.
If System.Diagnostics.Process.GetProcessesByName("firefox").MainWindowTitle = 'My Page Title'
...
End If
That said, there are much better ways to do this - If you're using firefox, look into GreaseMonkey, if in Chrome, look at TamperMonkey.
Both allow you to inject custom javascript into any page whose url matches a pattern you choose. In effect, you could write some Javascript to submit a form (say) 30 seconds after page load.
This would have the benefit of working if a different tab is selected as well as not requiring a whole application.
The SendKeys.Send method will indiscriminately send the key stroke to the active application. There is no way to use this API to target a specific application.
You could change your app to try and verify the active application is the one you want to send keys too. This is destined to be a flaky process though. No matter how good your verification is it's always possible that the active app is switched to another app after your verification completes.
If VerifyActiveAppIsTarget() Then
SendKeys.Send("{Enter}") ' Active app could change before this runs
I would persue a different solution for sending data between my apps
I've got a rather Javascript-heavy page with lots of contents generated via AJAX or other scripts. On some of these elements Selenium can record mouse clicks, while on others it ignores them. I haven't found any correlation. Perhaps there are some known common scenarios where Selenium cannot intercept mouse clicks?
Unfortunately not all clicks in Selenium are equal. Some are mouseDown and MouseUp or a variation on that. I would play around with that to get your app working.
Unfortunately Selenium IDE has been misrepresented. It is a Record/Tweak/Playback tool not a record/playback tool.
There's no list of actions that are unreliable. In my experience there's no pattern to which elements work, but it's consistent throughout executions of the test. In case you were thinking about it, playing around with locators or UI-Elements is very unlikely to improve your results.
I recently had a situation with a number of dropdown menus, all implemented in the same way, on multiple different pages. On certain pages, dropdown #2 and #3 wouldn't work, yet on other pages they would work, but dropdowns #1 and #2 wouldn't.
As has already been pointed out, the best thing to do is stop thinking about Selenium IDE as a record-playback tool.
On a sidenote, you may be asking this question for a similar reason I was, which was wanting to use Selenium IDE as a frontend for teammates without Selenium programming experience to create tests with, then one thing I did find helpful was extending the Selenium IDE by adding a Command Builder, which allows you to control what appears in the right-click menu when using the IDE.
This means you can press record, go about recording your test as normal while keeping an eye on what has been recorded. Once you see Selenium IDE has failed to record an action, you can just right-click the element and the action you wanted to record will be easily available.
Not a solution to your original question, but it's helped me out. It's very simple to write an extension to the right-click menu, there's some really good examples on this Selenium website.
I'm a 100% selenium noob, but I had the same problem and solved it through the following workaround:
Right-click the to-be-clicked item
Choose a random command that has the entire locator text, e.g. assertText //div[2]/div[5]/table/tbody/tr[1]/td[1]/div IR or something. Look inside "Show all available commands" too.
In the Selenium IDE, change the command to "click" and remove the 2nd argument (the Value field; if any)
Hacky, and should be easily improved with a custom command in the right-click menu, but for now this works fine for me.
Did you try clickAt with location (0,0)? It sometimes helps
If you have assigned an ID to the element you want to click I would suggest you try a simple script, you can perform this through the IDE:
runScriptAndWait
jQuery("#yourButton").trigger('click');
I have used this in the past and it works just fine.