As mentioned in various comments, solving general expressions involving an indeterminate $x$ and quaternions and addition and multiplication is hard. I avoid the word polynomial as it is a little ambiguous in this context. Note for example that $xi-ix+2k=0$ has $x=j$ as a solution, whilst $ix-ix+2k=0$ has no solutions.
However all your examples in the question are polynomials with real coefficients, and solving these is easy, again as stated in various comments. In case this was your actual question I will expand the comments a little:
Given any polynomial $P$ in $x$ with real coefficients, a general quaternion solution will have the form $q=a+b_1i+b_2j+b_3k$ with $a,b_1,b_2,b_3\in\mathbb{R}$. If $q$ not real let $$b=\sqrt{b_1^2+b_2^2+b_3^2},\qquad u=\frac1b (b_1i+b_2j+b_3k).$$
Thus $q=a+bu$. Here $u^2=-1$ (when you square $u$ all the cross terms cancel and you are left with $-1$). Now $u$ cannot be a root of any polynomial (in $y$) over the reals that is not divisible by $1+y^2$, as $1,u$ are linearly independent over $\mathbb{R}$. Thus $a+ib$ is also a root of $P$.
We conclude that if $q$ is a root of $P$ then either $q\in \mathbb{R}$ and is a real root of $P$, or $q=a+bu$ for a complex root $a+ib$ of $P$ and $u$ a unit vector in the (3 dimensional) plane spanned by $i,j,k$.
Thus if the roots of $P$ over $\mathbb{C}$ are: $$\lambda_1,\cdots\lambda_n, a_1+ib_1,\cdots,a_m+ib_m,$$ for $\lambda_r,a_r,b_r\in \mathbb{R}$, then the roots of $P$ over $\mathbb{H}$ are precisely:
$$\lambda_1,\cdots\lambda_n, \{a_1+ub_1,\cdots,a_m+ub_m|u \in S^2\},
$$
where $S^2=\{u_1i+u_2j+u_3k|\,\, u_1,u_2,u_3\in \mathbb{R}, u_1^2+u_2^2+u_3^2=1\}$.