Selenium Webdriver for Mobile testing - iphone

I'm getting the following error
ERROR running Appium command: Cannot call method 'send' of null
while running my selelnium test on iPhones. The same works on Android. What could be the potential issue? any help is appreciated.
The code that throws the error is :
public static boolean focusWindowByHandle(int inWindowIndex)
{
boolean blResult = false;
try
{
Object[] arrWindowHandles = GenericKeyword.driver.getWindowHandles().toArray();
if (inWindowIndex <= arrWindowHandles.length - 1) {
String strWindowHandle = GenericKeyword.driver.getWindowHandles().toArray()[inWindowIndex].toString();
GenericKeyword.driver.switchTo().window(strWindowHandle);
blResult = true;

I wanted to post this as a comment but I am posting it in this section owing to the readability.
Can you check if your version of 'appium.js' has the exact snippet as below?
logger.info('Shutting down appium session...');
if (this.isSafariLauncherApp === true) {
this.device.leaveWebView(function() {
if (this.device.udid === null) {
if (this.device.udid === null && this.device.instruments !== null) {
this.device.instruments.shutdown(function() {
this.cleanupSession(null, cb);
}.bind(this));

Related

Unity3D Webrequest SSL IOS CertificateHandler

Im trien to have a "Ignore all SSL Certificates" Checkbox for a Webrequest in Unity.
On Android it was working fine, but on IOS, I wasnt able to reset certhandler to default, it always returned true, once it was set. I tried dispose the handler by myself, set it to null and also I tried to clear cache.
Here is my code atm
using UnityEngine.Networking;
internal class AcceptAllCertificatesOrVerify : CertificateHandler
{
Main main = null;
protected override bool ValidateCertificate(byte[] certificateData)
{
if (main == null)
{
GameObject go = GameObject.Find("Main");
if (go != null)
{
main = go.GetComponent<Main>();
}
}
if (main != null && main.currentMandant != null && main.currentMandant.mandantIgnoreSSL)
{
main.ConsoleLog("ValidateCertificate: mandantIgnoreSSL");
return true;
}
else
{
if (main == null)
{
Debug.Log("ValidateCertificate: main null");
}
else
{
if (main.currentMandant == null)
{
main.ConsoleLog("ValidateCertificate: main.currentMandant null");
}
else
{
main.ConsoleLog("ValidateCertificate: main.currentMandant.mandantIgnoreSSL false");
}
}
}
main.ConsoleLog("Default ValidateCertificate");
return base.ValidateCertificate(certificateData);
}
}
it has some debugging activated, but when I check my adb log, I see only "ValidateCertificate: mandantIgnoreSSL". And never one of the other messages.
I also tried to set an remove certificateHandler dynamic like this:
{
webRequest.certificateHandler = new AcceptAllCertificatesOrVerify();
}
else
{
webRequest.certificateHandler = null;
}
But after AcceptAllCertificatesOrVerify was set once, I cant unset.
Is it a unity bug?

vertx-jdbc-client3.5.2 postgresql : sql update cause "A result was returned when none was expected"

In vertx-jdbc-client 3.5.0 ,the sql "DELETE FROM user;INSERT INTO user... " is ok.After update to vertx-jdbc-cient 3.5.2,the sql is fail with the error:
io.vertx.core.VertxException: org.postgresql.util.PSQLException: A result was returned when none was expected.By debugging, I found that the SQL was changed auto to DELETE FROM user RETURNING *;INSERT INTO user ..., then RETURNING * cause update error.
I find the cause:in vert-jdbc-client 3.5.0.
class JDBCConnectionImpl implements SQLConnection {
...
private SQLOptions options;
}
in vert-jdbc-client 3.5.2:
class JDBCConnectionImpl implements SQLConnection {
...
private SQLOptions options = new SQLOptions().setAutoGeneratedKeys(true);
}
then casue
public class Parser {
...
private static boolean addReturning(StringBuilder nativeSql, SqlCommandType currentCommandType,
String[] returningColumnNames, boolean isReturningPresent) throws SQLException {
if (isReturningPresent || returningColumnNames.length == 0) {
return false;
}
if (currentCommandType != SqlCommandType.INSERT
&& currentCommandType != SqlCommandType.UPDATE
&& currentCommandType != SqlCommandType.DELETE) {
return false;
}
nativeSql.append("\nRETURNING ");
...
}
Should I modify the SQL code or set up the JDBC client? Can anyone give me a suggestion?
I just found it's not a issue,because when i code SQLConnection sqlConnection = ...; sqlConnection.setOptions(null); ,then old sql update is ok.So it's a change,i think.

How to handle Servlet in login form?

I'm building a web application using only JSP pages and Servlets.
I'm trying to make a login form, but I can't access to home page.
Does anyone know how to handle this?
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
String username = request.getParameter("username");
String password = request.getParameter("password");
Iterator it = list_etudiant().iterator();
System.out.println("username" + username);
while (it.hasNext()) {
Etudiant et = (Etudiant) it.next();
String user_name = et.getEmailEtudiant();
String pass_word = et.getPasswordEtudiant();
if ((user_name == null ? username == null : user_name.equals(username)) && (pass_word == null ? password == null : pass_word.equals(password))) {
response.sendRedirect("View/Home.jsp");
}
}
} catch (Exception ex) {
Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
response.sendRedirect("index.html");
}
}
And another question, why I can't see the output in Netbeans console? For example when I want to print something:
System.out.println("username is : "+username);
I can't find the output and I just get this:
BUILD SUCCESSFUL (total time: 1 second)
if ((user_name == null ? username == null : user_name.equals(username)) &&
(pass_word == null ? password == null : pass_word.equals(password))) {
response.sendRedirect("View/Home.jsp");
}
I hope your rest of code work fine.
Refer to above code snippet. I guess your perspective is username & password should not be null & need to be equal.
if (((user_name != null) && (user_name.equals(username)))
&& ((pass_word != null) && (pass_word.equals(password)))) {
System.out.println("username is : " + username); // If you need to print it on console
response.sendRedirect("View/Home.jsp");
}
Your conditional checking is incorrect. Please refer ?: Operator

Add calling NUnit test to NLog output

I am running tests through NUnit and want to have NLog messages quickly tell me the calling test on each log message. Something like
<target xsi:type="File"
layout="${longdate} ${someMagic} ${message}"
/>
Is there an easy way to do that without diving too deep into NLog code?
Here's a working solution: a set of extension methods that wrap NLog ILogger.Error(..) method and the likes, looking up the stack for NUnit [Test] or [TestCase] Attributes
public static void XError(this ILogger log, String message)
{
if (log.IsErrorEnabled == false)
return;
var prefix = GetCallerTestDescription();
log.Error("[{0}] {1}", prefix, message);
}
private static string GetCallerTestDescription()
{
var stack = new StackTrace(false).GetFrames();
if (stack != null)
{
foreach (var frame in stack)
{
var method = frame.GetMethod();
var testAttributes = method.GetCustomAttributes<TestAttribute>();
if (testAttributes != null && testAttributes.Any())
{
return method.Name;
}
var tcAttributes = method.GetCustomAttributes<TestCaseAttribute>();
if (tcAttributes != null && tcAttributes.Any())
{
return method.Name;
}
}
}

GWT XMPP client using GWT-Strophe

I'm using GWT-Strophe to connect to my XMPP server. Things are going well and I am able to connect to my XMPP server and send other users messages. I'm having a problem with receiving messages. I'm attempting to copy the Strophe echobot example, but the code in my Handler is not getting executed when a message is received.
Here is the code I am using to connect and register the handler:
connection = new Connection("http://localhost/proxy/");
handler = new Handler<Element>() {
#Override
public boolean handle(Element element) {
GWT.log("Handling...");
GWT.log(element.toString());
String to = element.getAttribute("to");
String from = element.getAttribute("from");
String type = element.getAttribute("type");
NodeList<com.google.gwt.dom.client.Element> elems = element.getElementsByTagName("body");
if ((type == null ? "chat" == null : type.equals("chat")) && elems.getLength() > 0) {
Element body = (Element) elems.getItem(0);
GWT.log("ECHOBOT: I got a message from " + from + ": " + body.getText());
String[][] attributes = {{"to", from}, {"from", to}, {"type", "chat"}};
Builder reply = Builder.$msg(attributes).cnode(body.copy());
connection.send(reply.tree());
GWT.log("ECHOBOT: I sent " + from + ": " + body.getText());
}
return true;
}
};
StatusCallback callback = new Connection.StatusCallback() {
#Override
public void statusChanged(Status status, String reason) {
if (status == Status.CONNECTING) {
GWT.log("Strophe is connecting.");
} else if (status == Status.CONNFAIL) {
GWT.log("Strophe failed to connect.");
} else if (status == Status.DISCONNECTING) {
GWT.log("Strophe is disconnecting.");
} else if (status == Status.DISCONNECTED) {
GWT.log("Strophe is disconnected.");
} else if (status == Status.CONNECTED) {
GWT.log("Strophe is connected.");
connection.addHandler(null, null, "message", null, null, handler);
Builder pres = Builder.$pres(null);
connection.send(pres);
GWT.log("ECHOBOT: Send a message to " + connection.getJid() + " to talk to me.");
}
}
};
connection.connect("me#myserver.com", "password", callback);
Change your line
connection.addHandler(null, null, "message", null, null, handler);
with
connection.addHandler(null, "message", null, null, null, handler);
and it should work fine.
Can you post here how you connected gwt-strophe (if you successfully connected)?
Or if you found better solution please post it here. I've made GWT compatible module from gwt-strophe(included gwt.xml and all sources) and used in my GWT project. During compilation there was no error but when i called my widget it says "Cannot read property 'Connection' of undefined". After some code inspection i didn't found where Strophe object is initialized
private native JavaScriptObject connection(String boshService) /*-{
var connection = new $wnd.Strophe.Connection(boshService);
return connection;
}-*/;
Error thrown during runtime execution because window.Strophe object is undefined
p.s. i haven't found here how to add comment so i've made "answer" to ask question in this thread...
All i need is connection from GWT to my openfire server