How can I write a function in Selenium and call it from another page? - function

I'm new to Selenium. I need to write a function in Selenium. This is a sample code. If it is correct, where we will save this file and what is the extension? How can I call this function from another page?
Please help me.
Can you give me sample code for a function in Selenium?
package com.example.tests;
public void chk_test(String news){
System.out.println("Success");
}

For starters, use an IDE, such as Eclipse.
Within the same project, you should be able to create different packages, and import com.example.tests; within a class to use your function as chk_test(aString);
Hope this helps get you started. There are tons of articles/tutorials to get setup with Selenium RC using Eclipse, programming in Java.

Related

Accessing REST api from Windows CE

I have one Windows Handheld device application which has the requirement of accessing a REST API. The REST API gives me JSON output which I am going to handle via Newton.JSON. Now to achieve modular structure I want to have the communication to the REST API be handled via a different module altogether something like a Class Library. But unfortunately it seems that it is not possible to do so via a class library(or maybe possible). So my question is what is the best alternative to do so?
Please note that I don't want to include those connectivity operations in my front end application project. And I am using .Net framework 3.5 & Windows Mobile SDK 6.0
Thanks in advance
Pseudo class library code:
public function void startQuery() //starts a thread that does the JSON query
//inside thread on query result use OnDone() delegate
private delegate void OnDone(string dateTimeString);
//In main GUI code add a reference to the class lib and init a new object then add an event handler to the OnDone delegate of the class lib
JSONClassLib myJson=new JSONClassLib();
...
myJson.OnDone+=new EventHandler(myEventHandler);
void myEventHandler(sender this, objext o){
//will be called when query is done
}
//you need to use Control.Invoke if you want to update the GUI from myEventHandler
//to start a query use something like this from your class lib
myJson.doQuery(string);
If you add your existing code we may help with creating a class lib and async code
Now I got my answer. Sorry I did a mistake while selecting the project type. I selected "Windows Form Class Library" project instead of "Smart Device Class Library" project. Now that I have selected the right one it is working fine for me.
BTW thanks for those responses.
Cheers

Using Delphi component under C++ Builder makes calls to a wrong function

I'm trying to use Graphics32 package. Graphics32 was compiled and installed without any issue.
When I try to execute (debug) following code under C++ Builder XE3
TBitmap32* bmp = new TBitmap32();
bmp->LoadFromFile("d:\\sample.bmp");//This calls SaveToStream instead of LoadFromFile
...
it calls another member function SaveToStream which I can trace into and step while debugging until AV rises.
I have never encountered such behavior before.
Is there any compiler directive I'm missing or some workaround to make proper function call?
Update: I use the Graphics32 source from SVN. Everything works good if I use code prior to revision 2122.

How do i add a test project to the Eclipse environment created by JUnit for Plugin-testing?

I currently am working on an Eclipse plugin which needs to access the selected project in the Project Explorer. I have to provide JUnit tests, but i'm very unsure how to write proper tests for an Eclipse plugin.
I think JUnit is atleast properly creating a test-eclipse, since i can use calls like "PlatformUI.getWorkbench()" inside the test. But how do i setup a test-project inside this test-eclipse that my JUnit tests can work with? (I also need to set some of the project more internal stuff, since i'm checking natureIds and builderNames)
Thanks in advance for your answers! I would also be glad for links to a walkthrough of writing tests for an eclipse-plugin ;)
You write your tests in a plug-in as well, so that they're part of the executing Eciipse runtime. Then you have access to the APIs from org.eclipse.core.resources to create projects, folders, and files.
For creating a project specifically:
IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(name);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
// set nature IDs on the description here
try {
project.create(description, new NullProgressMonitor());
project.open(new NullProgressMonitor());
}
catch (CoreException e) {
e.printStackTrace();
}
return project;

cocos2d-x c++ -> java for android

Currently I'am developing a game using cocos2d-x.
Of course, for multi-platform use.
basically I use a xcode for coding and development.
I want to attach IAP(In app purchases) separately to each coding for iPhone and Android
Problem to try to call a function of a certain class in Android that did not work.
Sources include the following:
cpp side
MyClass::invoke_init()
{
JavaVM* jvm = JniHelper::getJavaVM();
JNIEnv* env;
jvm->GetEnv((void **) &env, JNI_VERSION_1_2);
jclass cls;
jmethodID method;
cls = env->FindClass("com/joycestudios/game/SampleActivity");
method = env->GetMethodID(cls, "initFunc", "()V");
env->CallVoidMethod(cls, method);
}
java side
public class SampleActivity extends Cocos2dxActivity
{
public void initFunc()
{
Log.v("LOG_INFO", "initFunc()");
}
}
The first test as follows: I'm in progress.
build from xcode and build from build_natvie.sh and last build from eclipse.
But after run on eclipse, Just black screen and shuts down.
How to call a function of a java class?
What I looked at several samples, including also analyze the problem, I do not see any problems?
Can you tell if you find any error log?
First check if your game is working fine on android..
Den we can have a look how to call the function.
Generally for calling native method I use MessageJni class available in Cocos2d-x library.
I create my methods in MessageJni class which calls for native methods.
Its easy and convenient way of calling native methods.
Just google using MessageJni class. It will ease your work.
:)

"Cannot call method 'indexOf' of undefined" when using Google Chrome (*googlechrome) as Selenium RC target

I'm trying to run a test in Google Chrome 9.0.597.98 beta using Selenium Grid. I'm firing the test off from C# using the default *googlechrome target that ships with Selenium Grid. When I try to open a site, I'm greeted with a "Cannot call method 'indexOf' of undefined" error.
I've found a post from someone who suggests that the solution is to drop security on Chrome a bit by passing in some parameters. This post suggest using something like this:
DefaultSelenium selenium = new DefaultSelenium(location, port, browser, targetPath);
BrowserConfigurationOptions bco = new BrowserConfigurationOptions();
selenium.start(bco.setCommandLineFlags("--disable-web-security"));
For some reason I don't see the BrowserConfigurationOptions anywhere. Is this something that ships with the Selenium dll? Is it something that's not available in the .NET version, but is in others? What options do I have to setting this "--disable-web-security" option and is there a better way of doing this?
Try this
[TestInitialize]
public void PreTest()
{
selenium = new DefaultSelenium("localhost",4444,"googlechrome","http://www.ryanhayes.net")
}
[TestMethod]
public void TestRyanHayesDotNet()
{
selenium.Open("/")
}
removing the / after the ryanhayes.net fixes the problem
Thanks a lot for this, I was looking this information and I got it here!
Now I'm able to run my test in googlechrome, earlier I was getting the same problem.
Following code is working for me:
BrowserConfigurationOptions webSec = new BrowserConfigurationOptions();
selenium.start(webSec.setCommandLineFlags("--disable-web-security"));
You're correct in assuming .Net doesn't have BrowserConfigurationOptions object, but fortunately you don't need it (it's only a thin wrapper). DefaultSelenium has two overrides for the Start() method. One of them takes no parameters and starts the browser normally, but the other takes a string specifying browser options. try selenium.Start("--disable-web-security")