how to turn off logging for Test Stack White? - white-framework

White is outputting a lot of logs to the Console and I want to turn it off to see my output. How is it possible? I tried the below but still see logs. Is there more code that needs to be added?
void func()
{
CoreAppXmlConfiguration.Instance.LoggerFactory = new WhiteDefaultLoggerFactory(LoggerLevel.Off);
// Open application and perform actions...
}

The code above seems to be working now.

Try to use ConsoleFactory instead of WhiteDefaultLoggerFactory.
CoreAppXmlConfiguration.Instance.LoggerFactory = new ConsoleFactory(LoggerLevel.Error)

Related

save display before calling a CDKpopup using C

Im trying to edit a program that capture user input. My intention is to add a function counting to a certain time. When it meet a timeout, a popup should be displayed. After that, the user should see back its previous shell/display. My problem is:
If the popup appear while the user are running vi, the display in that vi mode are hidden after the popup are destroyed.
Expectation: the user should have the same display as before the popup
Before the popup appear
After the popup destroyed
If the user are writing in a shell, it does not display the bash name (I do not know what its called. eg. fikrie#fikrie-VirtualBox:~/mysoftware/src$).
Expectation: the user should see the same display as before.
at the top line, the command (id) is displayed without bash name. I need to make the display same as the third line.
Im writing the code in C language and I'm using cdk library(ncurses) to do the popup. This is the function that create the popup.
int call_warning(struct tm *warning_display)
{
char *mesg[4];
WINDOW *cursesWin;
CDKSCREEN *cdkscreen;
char *buttons[1] = { "[ OK ]" };
char enddatetime[1024];
strftime(enddatetime, sizeof(enddatetime), "%d-%m-%Y %I:%M:%S%p", warning_display);
mesg[0] = "<C>----------------------";
mesg[1] = "<C>Your timeout is near";
mesg[2] = enddatetime;
mesg[3] = "<C>----------------------";
//I have tried using def_shell_mode() here
cursesWin = initscr();
cdkscreen = initCDKScreen(cursesWin);
initCDKColor();
while (1) {
popupDialogWithColor(cdkscreen, mesg, 4, buttons, 1, "</2>");
destroyCDKScreen(cdkscreen);
werase(cursesWin);
wrefresh(cursesWin);
endCDK();
endwin();
break;
}
//I tried using reset_shell_mode() here and removing system("clear");
system("clear"); //tried using refresh() as well. Didnt do the job
return 0;
}
From what i read in the manual guide, the def_shell_mode() will save the prior terminal settings so they can be restored during the call to endwin(). I tested using that but it doesnt solve my problem. I did google on how to clear screen using C. From the result, its either use curse or termios. I dont think termios is a good approach because I want to let the user continue its previous session and not making a new one. So my only option is curses. Is there any function in ncurses that can do this?
EDIT: After a few days trying, I found out CDK is the one causing problem. So I change my code to use curses function instead. The idea to do it is here.
How do you clear console screen in C?
How to clear screen from simple C program?

WPF MessageBox in App.xaml.cs stops MainWindow initialisation so app never appears but is (apparently) running correctly

There's no error message and no indication why it is not displaying the window. The app initialises App.xaml.cs: App() {} and I can step through the App.xaml file. It gets the startup uri and then... silence. No output in the Output window and no unhandled exception and no window, I can't find where to put a breakpoint to debug as it isn't hitting the start of MainWindow.xaml.cs.
Really confused.
This was working 20m ago.
In that time all I did was add Windows.Office.Interop.Outlook reference. I removed the reference and rebuilt but still the same. Would that cause this problem? Has anyone seen this before? Google isn't helping!
EDIT :
App.xaml.cs:
public App()
{
using (var dbContext = new DBEntities())
{
if (!db.Exists())
{
try
{
db.Database.Create();
MessageBox.Show("Database created"); // this is the problem!!
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
I've added App.xaml.cs, I found that the problem was using a MessageBox to give info (this is still in development!). I'd been meaning to get rid of it and eventually did and my problem went away. This meant I could find relevent Goolge results:
MSDN query and answer for exactly my problem
I will be adding an 'loading window' in between app load and main window load eventually in which I will be able to feedback information using Bindings etc.
Fixed error by removing the MessageBox.Show(..) call. The selected answer from the MSDN URL given in the question states:
"I performed a test based on your description, the applicationi stop at the method : USER32!GetMessageW+0x33, calling USER32!NtUserGetMessage"
I assume this is what was occurring in my case, although I didn't test it.
What happens if you create a new window and set that as the StartupUri?
You also might want to create a new project and make sure that the namespaces referenced in the App.xaml in your existing app haven't somehow been inadvertently edited.

CEF CefRenderProcessHandler::OnContextCreated not called

Who tried add native function to javascript in CEF? It was not work, simple to reappear:
download the CEF3 binary package (1750)
open cefclient2010.sln
open client_app.cpp which in cefclient project
goto line 110, set a breakpoint
F5
input any url, any try, the breakpoint never breaked
Am I missed some steps? or some settings?
i had the same problem
you must add CefRenderProcessHandler interface in SimpleApp ,then the most important is you must implement CefApp::GetRenderProcessHandler() method.
just like this:
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
return this;
}
by default, the base class return NULL,so OnContextCreated() will not call.
Perhaps it has something to do with the process model? How can you tell if the function is getting called? If by using a debugger, make sure you attached all child-processes too.
By default sample CEF application is multi-process. Either attach CEF render process to the debugger or simply do following (force the CEF app run into single process mode):
CefSettings settings;
#ifdef _DEBUG
settings.single_process = true;
#endif

HtmlUnit parses "http://www.ean-search.org/sitemap.html" with 404 return

I'm trying to get and parse the page "http://www.ean-search.org/sitemap.html", but it always got 404 error and empty page. All the text content area are blank.
I tried many options configuration of HtmlUnit webclient, e.g. .setThrowExceptionOnFailingStatusCode(false), setThrowExceptionOnScriptError(true), setRedirectEnabled(false), setJavaScriptEnabled(true), setThrowExceptionOnScriptError(false).
None of them worked...
Anyone have any suggestion? Thanks.
ps: my webclient code:
myWebClient = new WebClient(BrowserVersion.FIREFOX_3_6);
myWebClient.setIncorrectnessListener(new CustomizedInconnectnessListener());
myWebClient.setTimeout(180000); //3 min, used twice, first for connection, second for retrieval
try {
myWebClient.setUseInsecureSSL(true);
} catch (GeneralSecurityException ex) {
logger.log(Level.SEVERE, "cannot set UseInsecureSSL for BNP webclient",ex);
//ignore it, continue
}
myWebClient.setRedirectEnabled(true);
myWebClient.setCssEnabled(false);
myWebClient.setJavaScriptTimeout(30000); //timeout for executing java script
myWebClient.setThrowExceptionOnScriptError(false);
HtmlPage htmlpage = (HtmlPage) myWebClient.getHtmlPage("http://www.ean-search.org/sitemap.html");
myWebClient.waitForBackgroundJavaScriptStartingBefore(3000);
Thread.sleep(3000);
System.out.println(htmlpage.asXml());
Well, the code you're using looks really bad. I got many errors and warnings... it is not even possible to compile it. Eg myWebClient.getHtmlPage should be myWebClient.getPage.
This code works for me and outputs the content of the page:
WebClient myWebClient = new WebClient(BrowserVersion.FIREFOX_17);
HtmlPage page = myWebClient.getPage("http://www.ean-search.org/sitemap.html");
System.out.println(page.asXml());
Make sure you use the latest HtmlUnit libraries and also pay attention to the compiler when it tells you that something is deprectated. It is not advised to use those method and fields.

System.Diagnostics.Process.Start("http://google.com") crashes IE

Okay I'm having a brain fart here. This should be simple, but I'm missing something.
I've got a win form and I'm trying to launch a web page when I click a button. The code for the button is here:
private void button2_Click(object sender, EventArgs e)
{
try
{
System.Diagnostics.Process.Start("http://www.google.com");
}
catch (Win32Exception ex)
{
Console.WriteLine(ex.Message);
lblError.Text = ex.Message;
}
}
When I run this on my computer, it works fine. On other computers, it only works if you have a browser already open. If you don't have a browser open, it opens the browser then just hangs. What gives?
I've also tried
`System.Diagnostics.Process.Start("IExplore.exe", "http://www.google.com");`
ignoring the default browser (something I'd like to avoid but if it works, it works). I get the same result.
Thanks for your help.
EDIT: I'm also open to other methods of launching a web page with a button if any of you can think of one.
There's probably a better way to do it but this works...
System.Diagnostics.Process.Start("cmd","/c start http://www.google.com");
Okay, I got it working. I took Thinstall out of the equation and it magically works on every computer. Thanks guys for the help and suggestions.

Resources