Is there a way to turn off all Google Cast logging? - google-cast

I've set:
GCKLogger.sharedInstance().loggingEnabled = false
But I still see this printed out every time a Google Cast button appears on the page. It really pollutes my output log and is annoying (This is in GoogleCast framework version 3.5.0 / cast.ios.sdk_20170313.00_RC49):
> 2017-05-29 16:34:04.250 appName[22378:1706584] Logging 10, currently
> detected {(
> 1,
> 5 )}

Related

Change console.log timestamp in react-native or nodejs apps

After recent updates the log format in the console on react-native and maybe node apps, has become like:
This results after doing a simple console.log() call.
In previous versions the timestamp format was different, and a lot shorter. Is there a way to customize that date format?
I know what day is today, time only would save lots of space on my monitor.
I got no luck looking into the docs/source of react-native-cli.
Environment: npm 6.14.8, react 16.13.1, react-native 0.63.4
Searching a bit i found 3 ways to check logs:
Using android studio, the log format on the logcat can be changed using the settings icon, and you can remove the date
Using react-native log-android which formats differently the log using the logkitty package. example scrn of the log prefix outcome:
The default format on the metro bundler exists inside node_modules/metro/src/lib/formatLogTimestamp.js
It is currently (as of version 0.59):
module.exports = date =>
chalk.dim(
`[${date.toDateString()} ${date.toLocaleTimeString("en-US", {
hour12: false
})}.${String(date.getMilliseconds()).padEnd(3, "0")}] `
);
Change that to:
module.exports = date =>
chalk.dim(
`[${date.toLocaleTimeString("en-US", {
hour12: false
})}.${String(date.getMilliseconds()).padEnd(3, "0")}] `
);
After the change you need to restart metro,
and voila! you have only the time without the date.
(Obviously you need to make the change every time you remove/install the metro package)

Random failure of selenium test on test server

I'm working on a project which uses nodejs and nighwatch for test automation. The problem here is that the tests are not reliable and give lots of false positives. I did everything to make them stable and still getting the errors. I went through some blogs like https://bocoup.com/blog/a-day-at-the-races and did some code refactoring. Did anyone have some suggestions to solve this issue. At this moment I have two options, either I rewrite the code in Java(removing nodejs and nightwatch from solution as I'm far more comfortable in Java then Javascript. Most of the time, struggle with the non blocking nature of Javascript) or taking snapshots/reviewing app logs/run one test at a time.
Test environment :-
Server -Linux
Display - Framebuffer
Total VM's -9 with selenium nodes running the tests in parallel.
Browser - Chrome
Type of errors which I get is element not found. Most of the time the tests fail as soon the page is loaded. I have already set 80 seconds for timeout so time can't be issue. The tests are running in parallel but on separate VM's so I don't know whether it can be issue or not.
Edit 1: -
Was working on this to know the root cause. I did following things to eliminate random fails: -
a. Added --suiteRetries to retry the failed cases.
b. Went through the error screenshot and DOM source. Everything seems fine.
c. Replaced the browser.pause with explicit waits
Also while debugging I observed one problem, maybe that is the issue which is causing random failures. Here's the code snippet
for (var i = 0; i < apiResponse.data.length; i++) {
var name = apiResponse.data[i];
browser.useXpath().waitForElementVisible(pageObject.getDynamicElement("#topicTextLabel", name.trim()), 5000, false);
browser.useCss().assert.containsText(
pageObject.getDynamicElement("#topicText", i + 1),
name.trim(),
util.format(issueCats.WRONG_DATA)
);
}
I added the xpath check to validate if i'm waiting enough for that text to appear. I observed that visible assertion is getting passed but in next assertion the #topicText is coming as previous value or null.This is an intermittent issue but on test server happens frequently.
There is no magic bullet to brittle UI end to end tests. In the ideal world there would be an option set avoid_random_failures=true that would quickly and easily solve the problem, but for now it's only a dream.
Simple rewriting all tests in Java will not solve the problem, but if you feel better in java, then I would definitely go in that direction.
As you already know from this article Avoiding random failures in Selenium UI tests there are 3 commonly used avoidance techniques for race conditions in UI tests:
using constant sleep
using WebDriver's "implicit wait" parameter
using explicit waits (WebDriverWait + ExpectedConditions + FluentWait)
These techniques are also briefly mentioned on WebDriver: Advanced Usage, you can also read about them here: Tips to Avoid Brittle UI Tests
Methods 1 and 2 are generally not recommended, they have drawbaks, they can work well on simple HTML pages, but they are not 100% realiable on AJAX pages, and they slow down the tests. The best one is #3 - explicit waits.
In order to use technique #3 (explicit waits) You need to familiarize yourself and be comfortable with the following WebDriver tools (I point to theirs java versions, but they have their counterparts in other languages):
WebDriverWait class
ExpectedConditions class
FluentWait - used very rarely, but very usefull in some difficult cases
ExpectedConditions has many predefinied wait states, the most used (in my experience) is ExpectedConditions#elementToBeClickable which waits until an element is visible and enabled such that you can click it.
How to use it - an example: say you open a page with a form which contains several fields to which you want to enter data. Usually it is enought to wait until the first field appears on the page and it will be editable (clickable):
By field1 = By.xpath("//div//input[.......]");
By field2 = By.id("some_id");
By field3 = By.name("some_name");
By buttonOk = By.xpath("//input[ text() = 'OK' ]");
....
....
WebDriwerWait wait = new WebDriverWait( driver, 60 ); // wait max 60 seconds
// wait max 60 seconds until element is visible and enabled such that you can click it
// if you can click it, that means it is editable
wait.until( ExpectedConditions.elementToBeClickable( field1 ) ).sendKeys("some data" );
driver.findElement( field2 ).sendKeys( "other data" );
driver.findElement( field3 ).sendKeys( "name" );
....
wait.until( ExpectedConditions.elementToBeClickable( buttonOK)).click();
The above code waits until field1 becomes editable after the page is loaded and rendered - but no longer, exactly as long as it is neccesarry. If the element will not be visible and editable after 60 seconds, then test will fail with TimeoutException.
Usually it's only necessary to wait for the first field on the page, if it becomes active, then the others also will be.

Acumatica Test Framework: Time out Error

We have been trying to use the Acumatica Test Framework but unfortunately we are not managing to get our tests to run correctly.
We have followed the documentation step-by-step to set up the test accordingly. When we run the test, Firefox starts and the log-in page is loading correctly. The username and password are automatically entered, together with the company. The login-page completes successfully but is then resulting in an error.
The error is 'Timed out waiting for the WaitForCallbackToStart condition within the specified timeout: 500ms'
It seems that the test does not recognise that the log-in was successful.
I think I managed to identify the piece of code that checks whether log-in was successful:
"try\r\n{\r\n var win = window == window.top || !window.top.frames['main'] ? window : window.top.frames['main'];\r\n if (win.document.activePanel && win.document.activePanel.getInnerWindow()) win = win.document.activePanel.getInnerWindow();\r\n if (win.px_callback && (win.px_callback.waitCallback || win.px_callback.pendingCallbacks.length)) return true;\r\n else if (win.px_all) for(var item in win.px_all) if (win.px_all[item].callback) return true;\r\n return false;\r\n}\r\ncatch (e)\r\n{\r\n if (e.message.indexOf('denied') != -1 || e.message.indexOf('cross-origin') != -1) return true;\r\n else return false;\r\n}"
This represents a JavaScript code which is executed through Selenium to identify whether the Page has loaded.
However, the above code is returning false. The Test Framework continues to periodically call this code until it returns true (or times out). In my case it never returns true and times out.
We have tried on different versions of Acumatica and also on different machines. But it always results in the same error.
I am included a screenshot of the error below.
In the Visual Studio dialog in the Exception settings area set checkbox Break when this exception type is thrown equal to false and continue execution of the test. This exception is handled by Test SDK inside the LoginToDestinationSite function and you don't need to take care of it.

Using your NSURLResponse(webViewHack)

I now went to put this code check SO into another app and I am getting an error on the line:
if ((self = originalImp(self, _cmd, cf))) {
The build error is:
"Too many arguments to function call, expected 0, have 3"
I am using Xcode 6.2 compiling for iOS 7.1
Thanks
K
You can Disable the check in the Project Build Settings by setting 'Enable strict checking of objc_msgSend Calls' to No.
Has worked for me in similar situations. Filter the Build Settings on the keyword 'strict' to find it easily.

Getting Windows mouse event logs with win32evtlog

I want to get all stored event logs of my windows 8 machine using python 3.3 (especially the mouse event logs). I found a way of getting the event log file with win32evtlog module in python.
By reading the "System" logtype, I get a total number of 6594.
import win32evtlog
hand = win32evtlog.OpenEventLog("localhost","System")
flags = win32evtlog.EVENTLOG_BACKWARDS_READ| win32evtlog.EVENTLOG_SEQUENTIAL_READ
total = win32evtlog.GetNumberOfEventLogRecords(hand)
print("Total Number of Events:",total)
>> Total Number of Events: 6594
I suppose the mouse event logs an all other logs of a certain amount of size are in these approx. 6600 event logs. But when i try to loop/iterate over the events to get the information iwant, i just get back 3 event log objects.
import win32evtlog
hand = win32evtlog.OpenEventLog("localhost","System")
flags = win32evtlog.EVENTLOG_BACKWARDS_READ| win32evtlog.EVENTLOG_SEQUENTIAL_READ
events = win32evtlog.ReadEventLog(hand,flags,0)
print("LEN of event objects stored:",len(events),end="\n"*2)
>> LEN of event objects stored: 3
Am I on a wrong path for the solution ?
Or do you see whats wrong here ?
Everytime thankful for any help
I got the very same issue while trying to get startup and shutdown events. Apparently the issue is just the way you browse the events list, it should be done like here : http://www.blog.pythonlibrary.org/2010/07/27/pywin32-getting-windows-event-logs/
events = win32evtlog.ReadEventLog(hand,flags,0)
while events:
events=win32evtlog.ReadEventLog(hand,flags,0)
for event in events:
#do stuff here

Resources