How to view NSLog output of XCUITest and my app at the same time? - xcuitest

I can perfectly view NSLog lines in my Xcode 10.1 output window of my XCUItest, but I'm not able to see NSLog lines of my actual app/code in the output window.
How can I see NSLog output of my app and my testing at the same time in one window?
And if this it not possible, it would be great if I could switch between my XCUtest and my app output window during testing to see the respective NSlogs. I know I can switch the targets during testing, but if I switch to my real app I don't see any NSLog outputs.

These logs are visible in "Console" app.
If you open it and filter by your app name (PROCESS = app name), you will be able to see them.
It would be interesting to know how to do it in Xcode.

Related

Chrome: JSON (or other object) into chrome_debug.log

when I use chrome.exe with --enable-logging parameter it enables chrome to log console messages into debug file.
Sadly it missing the object details:
Example:
[1208:1164:1028/12048.086:INFO:CONSOLE(1)] "%c[WS Message] something color: #7c7c7c", source:something.js (1)
The (1) Stands for the JSON object inside I want to explore in real time in Python. Anyone have idea how to make chrome to save object as string for example in chrome_debug.log?? (Extension or some console command?)
Or any other solution that would enable to view the object in realtime in python?
(Yes i know you can right click on in actual chrome console by mouse then use "copy object", So yes, technicaly, i can make a macro which would do it in real time, but that woud be completely crazy.
I solved this by making Chome extension in Java, that copy-paste JSON objects from dev console. Little bit workaround, but better working that Selenium.

Copy variable from network tab preview in Chrome Dev Tools

I'm using the Chrome Dev Tools, and I am digging through the network pane to look at an XHR response with the preview tab. I want to grab a specific object from the preview. But when I try to store as global variable by right clicking preview object, the temp variable created was null.
I find that rather strange since the data is in memory (otherwise it wouldn't be displayed at all). Here's an example of a rather large response array that I'm trying to get a specific object from.
To clarify, I can store a variable that appears in my console. But I can't store a variable from the preview pane of the network tab. Is there any feature of the Chrome Dev Tools I'm overlooking, or am I forced to console log my XHR response and pull the object from there?
I'd really rather not add any console.log() or other breakpoints into my code just to have to remove them later. Digging through the super-long raw JSON response is also not practical. I'm using Chrome 47 on Windows 7.
I can get it to work by going:
Right click on the array index
"Store as global variable"
Then from the console, typing:
copy(temp1);
And then it will be on the clipboard.
Maybe a bit late, but you could go to response tab, copy the response content and then in the console just paste it after :
var response = <<paste here>>
i cant tell by the screenshot but you can then type response.data[64]

Firefox using old dataset for D3 visualisation

I have a web app which consists of a frontend HTML page where the user enters some search parameters, a PHP processing file which takes the search parameters and uses an online Web API to retrieve relevant data and then passes it to another HTML file, where the data is displayed in a dynamic bar chart with D3. The PHP process creates a JSON file, data.json, which is imported via $.getJSON in the second HTML page.
This works fine in Chrome and IE but not in Firefox. If I clear the browser history and run a search, then everything works fine. Any subsequent searches I do do not show the new data, but the data from that original search after the history deletion, even though the data.json file is updating correctly.
So this makes me think that Firefox is for some reason storing the initial data.json data somehow and using that data each time the page is called.
I haven't included any code because it seems more about the semantics of Firefox than a problem with the code. It did seem to start doing this after I styled the site with Bootstrap/Bootswatch but I don't see why that would have any effect.
Any ideas why this is happening, please?!

Wget source code for resulting webpage after querying?

I'm trying to count the number of times a searchbox errors when I do a bulk input of test data on a website. So I'm trying to wget the query result and seeing whether there is the word "Error" in the html result page. I am trying to download the resulting html webpage after I submit a query to a website. I build the query and used wget to download the resulting webpage.
However, only the main content of the html is shown and not the result because it was done by using an external javascript file. The html that I want can only be seen if I right click on View Page Source on my browser. Is there a non-manual way to use wget/curl to download such page source instead of having to click through all of them?
The javascript is a program, and the result of a program isn't deterministic in polynomial time (for arbitrary input). Thus, it's easier to load the javascript in a sandbox environment, and then execute it against test cases.
Wget and curl can't do that: they don't have any features to examine/execute the result of their fetch. Practically speaking, what you need is a browser that can efficiently load and test the script, as wget/curl from the shell. Luckily, there is already a such thing: Selenium. It is a firefox/chrome/explorer extension, which makes a running an instance of those browsers scriptable, and easily controlled remotely.
If you want to run these browsers noninteractively, without a gui, I suggest using a fake (hardware-less) X server.
Google for: selenium, and google for: headless X. Good luck!

Automate Chrome console from Desktop app?

I'd like to be able to send info to the Chrome developer console from my application.
For example, my app has some json. I'd like this json to show up in either an existing, or newly created instance of the chrome dev tools console.
Is this possible? If so, any pointers to examples? Note that the platform should be any language, not just javascript. And definitely not a site already running in Chrome. I'm interested in implementing this in another process.
Do you thought of running your app in an environment which is pretty much like a browser?
Node.js
or (this is a whole webkit browser)
phantom.js
Otherwise you could call Chrome directly via commandline and try to simulate the dev tools key stroke like explained here:
Is there a command line argument in Chrome to start the developer tools on startup?
The command of displaying something in the Chrome console is e.g. console.log and it is at the end Javascript. All Console commands are described here:
https://developers.google.com/chrome-developer-tools/docs/console-api
The closest I've seen so far is this library:
https://github.com/ccampbell/chromelogger
which seems to allow logging to the Chrome Console from lots of other server side apis, but no desktop APIs.
This can be done on Mac using osascript. Save the following as a script and run it:
#!/usr/bin/osascript -l JavaScript
var chrome = Application('Google Chrome');
//chrome.activate();
chrome.includeStandardAdditions = true;
var currentTab = chrome.windows[0].activeTab()
currentTab.execute({javascript: 'console.log("Hello")'})