How do I use Selenium IDE on Firefox to test JavaScript generated codes? - selenium

I am trying to test a website which contains alot of javascript.
Javascript does alot of opening new dialog to let user choose "yes" or "no".
It also has a function to upon right clicking, it opens up a right click menu which contains many functions such as zip, delete etc.
In Selenium, I can use the Selenium IDE to login, click, and others, but I don't know how to test those functions.
I've read there are codes I can write such as in Java to run the test, but I'm hoping to make it work by using the simple Selenium IDE if possible. If not, then can someone post a simple testing code which works to run java scripts? Such as click button -> javascript menu pops up -> click ok on the pop up.
Thank you very much.

Right context menus can be a little tricky. I'd suggest making custom commands for the right click context menu. Add the code from this article to your custom user-extensions.js file.
http://old.nabble.com/How-to-recognise-right-click-of-the-mouse-in-IDE-td14913052.html
The parameters for these functions in these commands become the expected arguments of your Selenium IDE commands. If you really want to make it simple, you can just call your javascript functions in these custom user-extension commands. :-) That might be a bit lazy and isn't truely testing what your right click is doing, but it would work.
Option #1 - if using IDE:
Specify the user-extensions.js file under Selenium IDE > Options (menu) > Options (menu option) > General Tab, then browse to your file under "Selenium Core Extensions".
Option #2 - if using Selenium RC Server:
If you're not using the IDE and using Selenium RC server with a client driver (like JUnit for example), you must specify the path of the *.js file with the -userExtensions parameter when you start the Selenium RC Server on the command line. But you said you just wanted to use the IDE, so I'd ignore this. It takes quite a bit of other setup to use the Selenium RC server.
java -jar selenium-server.jar -userExtensions user-extensions.js
=======================
I've never done this before, so I made the following custom command (JavaScript function) in my custom user-extensions.js file, and it worked well for me. I had to exit and restart the IDE before it found it. For some reason, you type everything after the "do" in the "Command" field in the IDE. It looks like it also added a "customAlertAndWait" to the IDE as well.
Code in user-extensions.js file:
Selenium.prototype.doCustomAlert = function(sTarget, sValue) {
alert('Target: ' + sTarget + ' ... Value: ' + sValue);
};
Selenium IDE command details:
Command: customAlert
Target: custom alert target
Value: custom alert value

The selenium IDE has a lot of tools to verify that specific elements are present and that the value is correct.
To set something up, you would create a test case, and start to record it. When you get to a page where you have to verify that something exists, right click on that element, and you will see a lot of Selenium commands tagged at the bottom of the click menu, such as "VerifyTextPresent" or "verifyValue" or "verifyElementPresent" When you select those commands, they will appear in your test case, and will fail if the verification fails.

Related

Intellij : Adding 'JUnit' to context menu when creating new file

Currently in Intellij if I try to create a new file via "New > whatever", I don't see any option to choose a JUnit file. I dug deeper and found out the "Edit File Templates...".
While you can add a variety of files from there to the context menu, there is no ability to choose JUnit.
If you browse over to "Code" tab you can see various JUnit templates. However I have no idea if these are just code generation templates instead of file generation templates. And besides, there is no option to port them to the "Files" tab.
The closest SO thread describing this issue is this and it failed to match my needs.
Mind you I am relatively new to Intellij and I come from eclipse.
P.S: I am aware you can generate tests from existing classes. I am currently trying to implement TDD so that does not answer my needs.
While I don't have an answer for this exact question, I think there's an easier way to handle the underlying requirements (easily creating tests):
Navigate to the class you want to test and press ALT+ENTER. In the context menu, pick "Create Test":
After you choose it, you'll get a dialog with several options including the framework to use (e.g., JUnit 5, JUnit 5, TestNG), the methods you want to generate test stubs for, etc:

Juno IDE for Julia, how to interact?

One way to comfortably use an IDE in an interactive language is to interact via the IDE in a command line environment. I am wondering if that is a possibility in Juno. In other words, is there a command line environment as in Matlab, to call functions, give initial values, and run expressions. If so what is the way to access it?
Note: There is a console window in Juno, but I can't find a way to insert my commands inside that.
Note: The question and this answer apply to the version of Juno that was based on LightTable. The current version is based on Atom and has an interactive console.
You can't enter commands into the console in Juno--that's for displaying output. Commands can be submitted from within the editor by setting your cursor in the line to submit and pressing Ctrl+Enter or Shift+Enter. The value will then be displayed in a small popup next to the line and the output will be printed to the console if you have the console visible.
Note that the inability to use the console as you desire is by design. See here for information about the console from the Juno docs.

Unable to pass the value using sendkeys in Selenium webdriver

I am unable to send any value to my application using webdriver. I'm able to click on the element. But SendKeys is not working, execution stops once I click on a Textbox.
driver.findElement(By.xpath("//table[#id='atgf']/tbody/tr[2]/td[3]")).click();
driver.findElement(By.xpath("//table[#id='atgf']/tbody/tr[2]/td[3]")).sendkeys("abc");
Try using the following way,
driver.findElement(By.xpath("...")).sendkeys(new String[]{"abc"});
Try using a Thread.sleep(time in ms) before entering the value in the text field. Sometimes that may be the issue.
Java compiler is set to 1.5 version change it to 1.6.
This is a very common problem with the Java compiler.
All you need to do is just set the Java compiler 1.6 from 1.5.
To change the Java compiler version, complete the following steps:
In the Project Explorer view of the Java EE perspective, right-click
the project and then select Properties.
Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.
Click Modify Project.
Double click the version number next to theJava facet to select a different level of Java compiler.
Click Finish to close the Modify Faceted Project window and then click OK.

Convert JUnit test case to Selenium IDE html file?

I have learnt how to export Selenium IDE html file to JUnit.
But if I make a change to the JUnit test - is there a way I can convert the Junit test to Selenium IDE html file so that even if I run the test from IDE the new change is recorded?
What is the best practice for such scenarios?
Note: (2nd user#Manii88), I am also facing the same issue...THough it might be an old question, it is still not solved yet...I find this question compelling because, say for example, I am in middle of some test, which i have exported from selenium ide and modified in Selenium Webdriver, eclipse, to check the viability of test cases and handling of popups...then, i want to continue my test case in ide...till the step completed, i want to proceed quickly and then, the next step, i will continue recording...
Hope this makes the scenario clear...Any answers???
Thanks!
Though it's not always possible, you may try the below steps to achieve it to some extent:
Install the latest Selenium IDE (or at least >= 1.6)
Open Selenium IDE
Options Menu > Format > JUnit 4 (Webdriver backed) [or use the same option here which was used while exporting html to JUnit]
Dismiss the warning dialog
Go to the Source tab, and paste your JUnit code
Change the format again back to HTML by selecting Options > Format > HTML
Dismiss the warning dialog
Switch (back) to Table tab to see your latest changes

Extract the contents of cmd.exe IDE to a text file using autohotkey scripts

I am trying to extract the contents of cmd.exe IDE to a text file using autohotkey scripts ie one test.ahk and its written as shown below:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
I am not able to extract the contents. Can anyone please suggest the correct way to do the extraction?
The text retrieved is generally the same as what Window Spy shows for that window.
The Window Spy shows no text elements for CMD windows - what you see is not necessarily what you can get :)
What you can do is to simulate the Select All and Paste commands, and then use the clipboard contents.
I don't believe you can extract the contents of a cmd window without somehow using DllCall to read the process memory directly.
If you just want the output of a CLI command such as Grep or AWK, using stdout via the run command should work. Honestly though, I stopped relying on AHK because this sort of thing is just too clunky.
http://www.autohotkey.com/docs/commands/Run.htm.
Edit for comments:
What you want is doable, but the solution depends entirely on how your IDE works. What behavior does it have that's unique to building a project? If it makes temp files, you can overload your "build" button with an AHK subroutine that watches for the existence of those files, and then checks the modified date of the output executable to see if the build succeeded. The same kind of solution works if the IDE changes its window title when building. Be clever. :)
Failing that, you might have to install a message hook.