Blocking Proxy is a tool for adding functionality to Web\+Driver-\/based tests. It sits between your tests and the Selenium Server. For each Web\+Driver command, it runs a set of \textquotesingle{}barriers\textquotesingle{} that will block forwarding the command to the Selenium server until some condition is met.

Because it interacts with Web\+Driver at the network level, Blocking Proxy can be used regardless of which language your tests are written in. See \href{https://github.com/angular/blocking-proxy/blob/master/examples/README.md}{\texttt{ the example}} for a demonstration of using Blocking Proxy with Web\+Driver tests written in Python.

Although Blocking Proxy can handle multiple Web\+Driver sessions, it can not yet handle multiple concurrent clients. Thus, it\textquotesingle{}s recommended to start a separate instance for each test process.\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3982}{}\doxysection{Usage}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3982}
Blocking Proxy can be installed globally with {\ttfamily npm install -\/g blocking-\/proxy}. You can also use it by cloning this repo and running these commands\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install}
\DoxyCodeLine{webdriver-\/manager update \&\& webdriver-\/manager start (in another terminal)}
\DoxyCodeLine{node ./built/lib/bin.js -\/-\/seleniumAddress http://localhost:4444/wd/hub }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3983}{}\doxysection{Features}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3983}
\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3984}{}\doxysubsection{Wait for Angular}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3984}
When testing an Angular application, Blocking Proxy can block webdriver commands until Angular\textquotesingle{}s change detection is finished, and thus make your tests less flaky.\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3985}{}\doxysubsection{Highlight Delay}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3985}
If {\ttfamily -\/-\/highlight\+Delay $<$delay\+MS$>$} is specified, Blocking Proxy will wait for the specified delay (in milliseconds) before executing click commands or sending keys. It will also highlight the element that is the target of the command.

Here\textquotesingle{}s an example of highlight delay in action\+:

\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3986}{}\doxysubsection{Web\+Driver logging}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3986}
When {\ttfamily -\/-\/log\+Dir $<$path$>$} is set, Blocking Proxy will create a readable log of Web\+Driver commands at the specified path. The log will look something like this\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{20:08:14.830 |    834ms | 37f13c | NewSession}
\DoxyCodeLine{    \{"{}browserName"{}:"{}chrome"{}\}}
\DoxyCodeLine{20:08:15.674 |      4ms | 37f13c | SetTimeouts}
\DoxyCodeLine{20:08:15.681 |    578ms | 37f13c | Go http://localhost:8081/ng1/\#/interaction}
\DoxyCodeLine{20:08:16.300 |    438ms | 37f13c | FindElement}
\DoxyCodeLine{    Using css selector \(\backslash\)'.invalid\(\backslash\)'}
\DoxyCodeLine{    ERROR: no such element }

\end{DoxyCode}
 Each line shows the command that was executed and how long it took. For some commands, extra data or the response from Web\+Driver will be shown on following lines.\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3987}{}\doxysection{Development}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3987}
\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3988}{}\doxysubsection{Formatting and lint}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3988}
{\ttfamily gulp format} runs clang-\/format. {\ttfamily gulp lint} validates format and runs tslint.\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3989}{}\doxysubsection{Running tests}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3989}
Unit tests live in {\ttfamily spec/unit} and can be run with {\ttfamily npm test}. Run {\ttfamily npm run test\+:auto} to automatically watch for changes and run unit tests.\hypertarget{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3990}{}\doxysubsection{Running e2e tests}\label{md_sfcode_node_modules_blocking_proxy_README_autotoc_md3990}
Start webdriver \begin{DoxyVerb}webdriver-manager update
webdriver-manager start
\end{DoxyVerb}
 in another terminal, start the testapp \begin{DoxyVerb}npm run testapp 
\end{DoxyVerb}
 Start the proxy with \begin{DoxyVerb}npm start
\end{DoxyVerb}
 in yet another terminal, run the tests \begin{DoxyVerb}npm run test:e2e
\end{DoxyVerb}
 