The direction of static friction? In my book, the following are described to be the steps that one must follow if he wishes to find the direction of static friction force acting on an object:

"(1) Draw the F.B.D(free body diagram) of the object in question with respect to the other object on which it is kept.
(2) Include the pseudo force also, if the contact surface is accelerating.
(3) Decide the direction of the resultant force and resolve this force into two components; one along the surface of contact and the other along the normal to this surface.
(4) The direction of static friction is opposite to the component of the result force along the contact surface."

Firstly, are these steps correct? Will I always obtain the correct answer by following these steps? Secondly, consider the following problem:

In questions like these, when I try to find the resultant force and then assign the direction to static friction, I find that my answer is incorrect! Are there some other steps to follow when I know that the object is definitely accelerating in one direction or another?
Edit 1: I approached the above question by doing exactly what my book suggests; first, I identified all the forces acting on the smaller block, being the normal force applied by the block A and its weight mg downward. Adding these two forces, I get another force that actually acts on the body like so:

I wonder if I'm not supposed to take either of the contact forces into consideration when drawing the F.B.D to figure out the direction of static friction acting on the body. Also, are there other steps for finding the direction of kinetic friction?
Edit 2: From Judge's answer, I have been able to figure out my mistake, it being that I completely missed step (3) and didn't resolve the resultant force into components! Sheesh. Sorry!
Much thanks in advance! :) Regards.
 A: 
Firstly, are these steps correct? Will I always obtain the correct answer by following these steps? 

Yes and yes, those steps are correct :)

Are there some other steps to follow when I know that the object is definitely accelerating in one direction or another?

I don't think so. Let's work through your example using those steps:
Inertial frame of table


*

*The 10kg block (B) has a weight force downwards, $\vec{W_B} = -mg \ \hat{y}$. A is accelerating into B, compressing it until B provides an equal and opposite reaction on A. We'll call A's force on B $\vec{N_{BA}}$ and it points right.

*In an inertial frame (e.g. the table's) we skip this step.

*Resultant force on B, $\vec{R_B}$ is the vector sum of all forces on B:  $\vec{W_B} + \vec{N_{BA}}$, pointing down-right. Resolving $\vec{R}$ into components perpendicular and parallel to the slope yields 
\begin{align}
\vec{R}_{parallel} &= \vec{W_B} \\
\vec{R}_{perpendicular} &= \vec{N_{BA}}
\end{align}

*The direction of static friction, $\hat{Fr}_{BA}$ is the opposite to $\vec{R_{parallel}}$ :  $$\hat{Fr}_{BA} = -\hat{R}_{parallel} = -\hat{W_B} = -(-\hat{y}) = \hat{y}$$

To stop the block slipping downwards, the frictional force must be equal and opposite to the downwards force
\begin{align}
\vec{Fr}_{BA} &= - \vec{W_B} \\
\mu |\vec{N_{BA}}| \hat{y} &=  -(-mg)\hat{y} = mg\hat{y}
\end{align}
If you consider the horizontal components you can see that $|\vec{N_{BA}}| = m|\vec{a}|$, so 
$$
|\vec{a}| = \frac{g}{\mu} = 19.62 \ \text{ms}^{-2}
$$
Non-inertial frame of block B


*

*Same as in inertial frame.

*A's and B's frame is accelerating with respect to the table, so we add a pseudo force $\vec{P}$ pointing left. B is also accelerating downwards (due to gravity), so we add an additional pseudo force pointing up. We then add these 2 pseudo forces to every other object in the system (A and the table).

*The resultant force on B is zero: $\vec{R}_B = 0$, which is not surprising in it's own frame. To get static friction, consider what happens to A from B's perspective. The resultant force on A is $\vec{P}_{vert}$, which accelerates it upwards. 

*The direction of static friction on A from B is in the opposite direction to  $\vec{P}_{vert}$
$$
\hat{Fr}_{AB} = -\hat{P}_{vert} = -\hat{y}
$$
Every action has an equal and opposite reaction (cheers Newton!), so we also have a static friction on B from A
$$
\hat{Fr}_{BA} = -\hat{Fr}_{AB} = -(-\hat{y}) = \hat{y}
$$
which is the same as in the inertial frame.  



To stop A slipping upwards past B, the frictional force on A must be equal and opposite to the upwards force 
\begin{align}
\vec{Fr_{AB}} &= - \vec{P_{vert}} \\
            &= -(-W_B) \\ 
-\mu |\vec{N_{AB}}| \hat{y} &=  -(--mg)\hat{y} = -mg\hat{y}
\end{align}
If you consider the horizontal components you can see that $|\vec{N_{AB}}| = m|\vec{a}|$, so 
$$
|\vec{a}| = \frac{g}{\mu} = 19.62 \ \text{ms}^{-2}
$$
which is also the same as in the inertial frame... nailed it! :) Now if you're like me, you're probably thinking "that was the worst piece of nasty, hateful, misery I've ever seen." And you'd be right! My advice would be just pick an inertial frame and be done with it.
Edit 1: Simple example
Let's walk through a more simple example; just block A and the table (no block B).
Inertial frame


*

*See the diagram below. I start by adding all the original forces (left) and then I add all the action-reaction pairs (right).

*Skip this step, because there's no pseudo forces in inertial frames

*Take the vector-sum of all forces on A to calculate the resultant force on A, $\vec{R_A}$
\begin{align}
\vec{R_A} &= \vec{D} + \vec{N_{AT}} + \vec{W_A} \\
          &= D \hat{x} + (N_{AT} - W_A) \hat{y} \\
          &= D \hat{x} + 0 \hat{y}
\end{align}
Now we resolve $\vec{R_A}$ into components that are parallel and perpendicular to the slope
\begin{align}
\vec{R}_{parallel}       &= D \hat{x} \\
\vec{R}_{perpendicular}  &= 0 \hat{y}
\end{align}

*We know the direction of static friction is opposite to $\vec{R}_{parallel}$, so $\hat {Fr_{A}} = -\hat{x} $. Done :)

Non-inertial frame


*

*Start with the same as before

*We add pseudo forces to all objects, such that the resultant force on A is zero, which is what one would expect in a frame, in which it's not moving. However, the resultant force on the table is now not zero.

*The resultant force on the table is the vector sum of all forces on it
\begin{align}
\vec{R_{T}} &= \vec{P_{horz}} + \vec{N_{TG}} + \vec{W_T} + \vec{W_A} + \vec{N_{AG}} \\
            &= -P_{horz} \hat{x} + (N_{TG} - W_T + W_A - N_{AG})\hat{y} \\
            &= -D \hat{x} + 0 \hat{y}
\end{align}
Resolving this into components:
\begin{align}
\vec{R}_{T, \ parallel}       &= -D \hat{x} \\
\vec{R}_{T, \ perpendicular}  &= 0 \hat{y}
\end{align}

*The direction of static friction on the table is opposite $\vec{R}_{T, \ parallel}$:
$$\vec{Fr}_{TA} = -\vec{R}_{T, \ perpendicular} = -(-D) \hat{x} = D \hat{x}$$
Every action has an equal and opposite reaction, so as A is exerting a frictional force on the table rightwards, the table must be exerting a frictional force leftwards on A and voila 
$$
\hat{Fr}_{AT} = -\hat{Fr}_{TA} = -\hat{x}
$$

Edit 2: Answer to comment
To be honest, pseudo forces make my brain explode. There's a helpful example over on wikipedia. In the example, the person is analogous to block B and the seat is analogous to block A. If you imagine being block B it's like being accelerated in a car; you get pushed back into your seat (which is the pseudo-force). Then at constant velocity you feel like your not moving, but the road is moving under you. 
It's always worth bearing in mind these useful rules:


*

*The magnitude of static friction is always less than or equal to the magnitude of the driving force

*Frictional forces, like all forces, come in action-reaction pairs

*You can take any frame of reference you like (in classical mechanics). After all, what's stopping you? 

*Pseudo-forces are just the result of coordinate transformations :)


I'll leave what happens in A's frame as a fun exercise for you.
A: There does not seem to be an error in those steps assuming that you do NOT include the static friction in steps 1-3. The static friction would be added after those steps. 
Remember that the static friction will be parallel to the contact surface causing the friction on the object.
EDIT: There is a situation in which these steps can get tricky. That would be one in which there are no outside forces parallel to the contact surface if you ignore static friction. Consider a block resting on a piece of paper on a horizontal surface (a table). You gently pull horizontally on the paper and the block slides with the paper, relative to the table but at rest on the paper. Static friction between the paper and block makes the block move, but there are no other real horizontal forces to use in steps 3 and 4. But the reference frame of the paper is accelerating with respect to the table, so one would draw a pseudo-force opposite the acceleration of the paper.Then the direction of the static friction will be opposite the direction of the pseudo-force, which is in the "forward" direction. (And that is why I don't like to use pseudo-forces .... ;) ).
I much to prefer to play a thought experiment and see what direction the object will slide on a surface if there is zero friction. Then the friction is opposite that sliding direction.
A: @Judge gave a quite good answer on how to follow your steps, but I will point out that there are other steps to follow than those you have listed, which will avoid pseudo-forces.

Are there some other steps to follow when I know that the object is definitely accelerating in one direction or another? 

Yes, there are. And I personally find it much simpler.
Specifically, a simple method is to just randomly choose the direction of the static friction and add it to the free-body diagram. In the problem given, it must be either up or down, so let's say that we choose down. Then, when solved, if the result is positive then it was correct and the direction was indeed downwards; if the result turns out to be negative, you have chosen the wrong direction and it is upwards instead. In any case you get it right in the end, because a minus on a force just means that you should flip the force vector.
So, outlined, the steps would be:

a) Draw free-body diagram (for a stationary frame) and
b) draw static friction in a random direction along the contact surface (there are just two choices).
c) Solve the whole thing with Newton's laws as always. 
d) When you have found the value of static friction, look at it:
  
  
*
  
*Is it positive then all is good;
  
*is it negative then you chose the wrong direction and you must flip it around.
  

In the problem given, the box on the side would have a free-body diagram with normal force $\vec n$, weight $\vec w$ and static friction $\vec{f_s}$. We set $\vec n$ rightwards, $\vec w$ downwards and let's choose $\vec{f_s}$ downwards as well as are arbitrary choice. Setting up Newton's 2nd law for the horizontal and vertical directions give:
$$\sum F_x=m a_x\quad\Leftrightarrow\quad n=ma\\
\sum F_y=m a_y\quad\Leftrightarrow\quad -f_s-w=0
\quad\Leftrightarrow\quad f_s=-w=-mg$$
It here turns out that the value of $f_s$ is negative, so the chosen direction of the force vector $\vec{f_s}$ is wrong. It should rather be the other way: upwards.
If you had chosen upwards as the direction from the start, the equations would have become:
$$\sum F_x=m a_x\quad\Leftrightarrow\quad n=ma\\
\sum F_y=m a_y\quad\Leftrightarrow\quad f_s-w=0
\quad\Leftrightarrow\quad f_s=w=mg$$
The value of $f_s$ is positive, so the chosen direction is correct: upwards.

The given problem is quite simple since acceleration doesn't have any influence on the direction. If it was an incline moving instead of a wall, it would have. In that case you must know the direction of the acceleration - because you can't have two such unknowns where we don't know the directions. But usually you also do know or is able to easily guess the acceleration direction.

An extra comment to be aware of is that it is often easy to guess/see what the direction is right away before you begin. In the given problem that is possible.
Because, remember what static friction does: it tries to prevent sliding. So, it must always "hold back", when other forces try to start slide. It always "holds back". In your given problem, you can farely easily see that gravity pulls downwards with the weight $w$, so naturally static friction "holds back" by pulling upwards.
This easy and quick calculation-less method of "seeing" the direction is often possible because it often is clear in which direction the other forces (namely the resulting force) pull. But in some cases with many forces present in both directions this is not easy to see; for example if I was pulling up with a rope in the box in the problem. Then I would have an upwards pulling force, and the weight would still be downwards, and then the direction of static friction depends on which of these that "counts the most". If I pull a tiny bit, then the box would fall without static friction to help to hold up. But I pullvery much - more than gravity pulls - then the static friction must hold back downwards, to avoid the box from sliding up.
