I read several posts on this but I could not fix my problem which is that eclipse skips a conditional I defined on a variable.
if(currentContent=="content") {
return true;
}
Can you please advice what I should do for the conditional to trigger the breakpoint when the value of my string variable is equal "content".
You can't rely on == with Strings. Use .equals().
nitind's point about using .equals is important, but I think a bigger issue is that the breakpoint condition is evaluated BEFORE the line executes, not after. I get the feeling you want to hit the breakpoint when the resulting value of "currentContent" matches your expectations AFTER the assignment, not before.
In this case, I suggest you move your breakpoint to the executable line that comes after this line.
Related
I am very new to Selenium and Eclipse.
I have a question (actually 2 questions) about debugging.
When I am debugging in Eclipse (Version: 2021-06 (4.20.0)), so I do not get visibility of all variables I have defined in the method.
For example, (see the screen shot attached) I have added string variable testSigned and assigned a value to it. Actually the purpose is to verify the text value contained in web element table_AdditionalDocumentation.
I defined Toggle Line breakpoint at line 395.
I started to execute in debug mode, got to the line 395.
However, I do not see the value of testSigned in Variables tab.
I noticed it does show values only of the variable which would be returned by the method, correct me if I am wrong.
Please, tell me how to get those values I have defined visible.
2.Additionally, please, let me know which button to press if for example after line 395 I want not to go line by line (F6), but just to run the code to the end.
For the first question, I'm not certain, but it might be because you haven't initialized that variable with a value. Try setting it to an empty string on the declaration line.
For the second question, if you set a breakpoint on the line you want to get to, just Resume (F8), and it will stop at the next breakpoint it hits, hopefully the one at the end of your method. Alternatively, if you just want to stop at the line right after the method returns (which will show the return value), you can click "Step Out" (F7) for that.
Is there a possibility to step to any following line while debugging in eclipse?
It will help debug situations when I have a breakpoint at method beginning, I check something there, and below there is a for loop that i want to step through fast to see all changes it made at once.
Currently in the above scenario I put a breakpoint below the for-loop, hit F8, remove the breakpoint after execution stops which is pretty cumbersome.
Is there a better method of doing above?
Put break point at start of function.
Check XYZ. Come up to for loop.
Put your cursor after for loop.
Press CTRL + R.
HURRAY!!!!! I skiped for loop in debug.
I have used Eclipse and VS. When I insert a breakpoint and debug the program, it will stop before the breakpoint.
But what if I want to debug the effect of the last sentence of the program? Inserting a meaningless sentence(say print 'pause' in Python) is OK but seems awkward. Is there any alternatives?
In Visual Studio you can put break point on closing bracket in main (or any) method of Program (or any) class (default naming, may vary), then debugger stops just before closing application.
Is there any reason not to use a breakpoint on the last statement, like you said, then manually proceed one step? Depending on the debugger, this can also be automated. In GDB, one can use commands N, where N is the breakpoint number, to set a list of (debugger) commands to be executed immediately after a breakpoint is hit.
Is there any command using which we can inspect a object in command line while app is running in DEBUG mode. I do not want to put description message in the code.
Try these resources. one two
(gdb) p varName
Yes sure. If you are debuging, breakpoints are automatically set to on. Just set a breakpoint to the line in which the variable is. The program stops as soon it reaches the line with the breakpoint. Just hold the cursor over the variable and all important data is displayed. I do it also that way all the time. ;-)
Is it possible to debug PHP scripts so that it keeps running until an expression is true?
For example, I want to know when $a becomes a certain value. I don't want to keep pressing step into and wait until the variable $a changes the value to it.
The solution is to set a breakpoint, right click on it and set a condition for it.
However, there are no global breakpoints, you must specify a location for every breakpoint you put. So, if you want to know where a value changes, you can't set any global conditions as they would be too CPU consuming.