File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -129,18 +129,37 @@ public function _failed(TestInterface $test, $fail)
129129 */
130130 public function _before (TestInterface $ test )
131131 {
132- if (!$ this ->hasModule ($ this ->config ['module ' ])) {
132+ $ browserModule = $ this ->getBrowserModule ();
133+
134+ if ($ browserModule === null ) {
133135 throw new \Codeception \Exception \ConfigurationException ("VisualCeption uses the WebDriver. Please ensure that this module is activated. " );
134136 }
135137 if (!class_exists ('Imagick ' )) {
136138 throw new \Codeception \Exception \ConfigurationException ("VisualCeption requires ImageMagick PHP Extension but it was not installed " );
137139 }
138140
139- $ this ->webDriverModule = $ this -> getModule ( $ this -> config [ ' module ' ]) ;
141+ $ this ->webDriverModule = $ browserModule ;
140142 $ this ->webDriver = $ this ->webDriverModule ->webDriver ;
141143
142144 $ this ->test = $ test ;
143145 }
146+
147+ protected function getBrowserModule () {
148+ if ($ this ->hasModule ($ this ->config ['module ' ])) {
149+ return $ this ->getModule ($ this ->config ['module ' ]);
150+ }
151+
152+ foreach ($ this ->getModules () as $ module ) {
153+ if ($ module === $ this ) {
154+ continue ;
155+ }
156+ if ($ module instanceof WebDriver) {
157+ return $ module ;
158+ }
159+ }
160+
161+ return null ;
162+ }
144163
145164 /**
146165 * Get value of the private property $referenceImageDir
You can’t perform that action at this time.
0 commit comments