Protractor - Return the operating system - javascript

Does anyone know how to return the operating system using Protractor?
A little context: I need to press some keys (I think I'll be using action sequence to do so) but as the keyboard is different for MAC and PC, I think I need an if statement detecting which OS I'm running the tests on. If anyone knows a better way to do this? It's further compounded by the keys being relatively unusual (fn + F10) on MAC and just F10 on PC.
Any help much appreciated!

Protractor runs on node, so you can use the inbuilt node variable process.platform.

Related

Can Javascript detect UWP?

I'm building a little game using NodeJS and EaselJS that runs great in-browser, locally hosted. I downloaded Visual Studio and started the process of creating a UWP from it so that I can play on my Xbox One. Visual Studio is basically just the middle man, as I am using the "Start Page" and pointing it to my locally hosted web server to create the app, rather than try to re-invent the wheel.
I'd like to take advantage of some of the Windows.UI functions ONLY WHEN it's run as a Window/Xbox app, specifically the Overscan ability for display on a TV. So far I've been unable to get the JS to detect the execution type. I've added
if (Windows)
{
Windows.UI.ViewManagement.ApplicationView.getForCurrentView() ...
}
but when I run it in a regular ol browser I get a Reference error of Windows being undefined. I also tried
if(typeof Windows !== 'undefined'){....
which makes the browser version work fine, but deployment tests in Visual Studio don't see it either (I put a debug console output to make sure).
Is it possible to have a best of both worlds execution, or do I need to go full bore and develop a specific version of the game in VS to get what I want?
Figured it out. The if(typeof) solution is partially correct, so points there Shawn. What I was failing to do is include WinRT Access to the URI in the appxmanifest inside of Visual Studio. Once I told it to actually look for Windows on the app side, I'm getting my debug output and the screen is scaling appropriately. Thanks for having a look see anyway!
I can think of two possible options. First check the type of the object:
if(typeof Windows != 'undefined')
{
}
Second, declare a variable Windows before your check(s). It's ok to redeclare a variable in javascript. It won't override the original.
var Windows;
if(Windows)
{
}

iPad Javascript Debugging

We have a huge client-side application that doesn't work at all on an iPad and we have no idea why.
Unfortunately I don't have a book way of showing or explaining a particular piece of Javascript that doesn't work because from what we call tell, there are none.
Can any heavy Javascript users give me some clues how we can troubleshoot this?
PS - We are a Windows shop, but I would be willing to go buy a MacBook Pro to troubleshoot if need be, but I'd obviously prefer to save the 2 grand if I can.
I don't use Windows, but I assume you could use virtualization software to run OSX on a PC and then use the Safari remote web inspector:
https://developer.apple.com/safari/tools/
It looks like there are also two tools available if that doesn't work:
https://people.apache.org/~pmuellr/weinre/docs/latest/Home.html
http://www.telerik.com/platform#test

titanium android runtime error box always shows wrong line number

i am developing an cross platform application in OSX mavericks environment with titanium sdk 3.3.
While debugging on android the runtime error caught always show [1,69] for line number.So i can't spot exact position of actual error.
The same environment run smoothly on IOS application.
Any one please suggest a solution.Thanks in advance.
As far as I am concerned android errors show the line of code in the final "java binary" file and not the actual line in your Titanium source code.
Maybe you should report this as a bug report to the Appcelerator team.
The Android environment appears to be less forgiving than the IOS environment when working with Titanium. Often, after I've written my app to work for IOS, I then need to fix it to work on Android. On the positive side, these always appear to be actual errors that I guess the IOS environment either assists with or doesn't find critical enough to stop the program execution. When I fix the code to work for Andriod, it almost always works for IOS as well with the need for branching.
Just because your code is working on IOS doesn't mean you don't have a bug in it. I find that the Android debugging process helps me strengthen the quality of my app as a whole. Don't ignore the error on the Android side at [1,69], there is likely an issue there. Perhaps an unassigned variable or a null object.
Titanium studio most of the time won't show us the exact line number in our code. This holds for both iOS and Android. Other commenters have shared their thoughts about the reasons behind. I accepted that this is the price I have to pay for close to native experience. (at least for now)
The best solution I found to work like this, is to learn how to use the debugger in Titanium studio. You can add the Debug Perspective in the upper right corner with the Open perspective button. This will give you a Studio layout tuned for debugging. I use this view to fix complex problems.

How to debug web app on windows mobile (7 and later) [duplicate]

I'm not a Windows Phone developer, and I want as little to do as possible with anything related to Microsoft. Nonetheless, I need to get my mobile web app running properly on Windows Phone 7. What debugging tools are available for the platform? Something like the Webkit developer tools or Firebug would be ideal, either from the phone itself or more likely, remotely debugging from my computer.
If such a thing doesn't exist, I'd settle for being able to read Javascript error messages, and view the contents of variables using alert() or similar. At this point, all I know is that my JS is failing: I don't know where or why, let alone how to fix it.
My dev computer is running OS X, and I'd really like to be able to use these tools from OS X if possible. Assuming that debugging tools exist (which I really hope they do) are they designed for Windows only? If so, does anyone know how well they would work with Wine or similar?
EDIT: I have a physical Windows Phone 7 device, so I can use that. However, alert() doesn't seem to be working, which is why I'm posting this question. Does alert() normally work on the WP7 browser?
You'll likely find the Mobile Perf Bookmarklet to be the easiest all-in-one tool for testing any mobile device.
Works well on the iPhone/iPad/Samsung Galaxy Tab in my testing so far.
Quote:
It displays a menu with links that load other bookmarklets including Firebug Lite, Page Resources, DOM Monster, SpriteMe, CSSess, and Zoompf.
Unless you have a Windows Phone 7 device, you will need to run Windows in BootCamp and install the Windows Phone Developer Tools in order to test in IE on the emulator. I don't know about Whine, but I ran into major problems trying to test in Parallels - so based on my experience, I suggest keeping it as simple as possible.
There is no console in IE on the phone, so you will need to use alert, like you suggested, or just write text to a div on your page as a custom console.
If you really want to code in OS X (which I definitely understand), using a separate machine for testing IE in the WP7 emulator is going to be your best bet.
EDIT: I just tested alert and it did work fine on my Windows Phone. My guess is that a syntax error is preventing it from calling.
The following may be interesting
Simple IE debug tool for Windows Phone
Supports
Html traversing
Html node styles, properties, metrics
Reading console output
Executing js on device side from console (including intellisense)
Dynamic script injection - ability to debug live sites
Not supported
js breakpoints
Just wanted to add a note to say that full JavaScript debugging is possible now with Windows Phone 8.1 and Visual Studio 2013 Update 2. Full details are available at:
http://blogs.msdn.com/b/visualstudioalm/archive/2014/04/04/diagnosing-mobile-website-issues-on-windows-phone-8-1-with-visual-studio.aspx
I realize that this doesn't help the versions referenced in the original question (WP7), but I'm hoping this will help people who may find this question and are running a more recent version.
Something that has worked for me, is to test my mobile pages through the Windows Vista built-in Internet Explorer browser.
It comes with a script debugger ( which you have to enable in Advanced Options tab through the Internet Options menu ), and it seems that it gets really close to the Internet Explorer Mobile implementation.
Another tip would be, that, instead of using window.alerts, you can also use document.write or set output to a div content.
I'm using this hack to have console.log send info back to the server (it uses window.fetch, which I'm polyfilling, but could use xhr instead) https://gist.github.com/wheresrhys/bf93057ee3a594454582

How do I run a system command in a cydget using objective c or javascript?

I am trying to run a Ruby script from a cydget (cydget is a framework made by Saurik for writing lockscreens on the iPhone, using cycript, which is a mix of javascript & objc - see http://www.cycript.org/ ) The script will first check to see if a WEBrick server is running, if so it will quietly exit, if not it will start the server.
Apparently the iPhone doesn't support NSTask, and I don't know if the cycript implementation of obj-c does or not. (To be honest, I have no clue how obj-c in cycript works at all!) I'm not worried about security, because I'm running 1 specific command: "ruby server.rb", and everything else will be handled through the web server itself.
Is there any way other than NSTask in objective-c, or any way in javascript or HTML that I can run an arbitrary command on the local machine?
Thank you!
Brent
You can't fork another process on an iPhone at all (assuming we're talking about a legitimate app developed against Apple's official SDK). No NSTask, no fork()/exec(), no system(), nothing.
So it sounds like the best solution is to just wait - Saurik will be coming out with a way of directly using Ruby in a cydget, but it likely won't be out for a few months... :( I hope it will be worth the wait though!

Categories

Resources