Skip to content

Commit b0a3536

Browse files
committed
Update toForeground logic in WebdriverProtocol
1 parent 6b24c51 commit b0a3536

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

testar/src/org/testar/protocols/WebdriverProtocol.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.google.common.collect.ArrayListMultimap;
3434
import com.google.common.collect.Multimap;
3535
import org.apache.commons.lang3.ArrayUtils;
36+
import org.apache.logging.log4j.LogManager;
37+
import org.apache.logging.log4j.Logger;
3638
import org.openqa.selenium.logging.LogEntries;
3739
import org.openqa.selenium.logging.LogEntry;
3840
import org.testar.environment.Environment;
@@ -48,6 +50,7 @@
4850
import org.testar.monkey.alayer.webdriver.Constants;
4951
import org.testar.monkey.alayer.webdriver.enums.WdRoles;
5052
import org.testar.monkey.alayer.webdriver.enums.WdTags;
53+
import org.testar.monkey.alayer.windows.WinApiException;
5154
import org.testar.monkey.alayer.windows.WinProcess;
5255
import org.testar.monkey.alayer.windows.Windows;
5356
import org.testar.plugin.NativeLinker;
@@ -65,6 +68,9 @@
6568
import static org.testar.monkey.alayer.Tags.Enabled;
6669

6770
public class WebdriverProtocol extends GenericUtilsProtocol {
71+
72+
protected static final Logger logger = LogManager.getLogger();
73+
6874
//Attributes for adding slide actions
6975
protected static double SCROLL_ARROW_SIZE = 36; // sliding arrows
7076
protected static double SCROLL_THICK = 16; //scroll thickness
@@ -268,11 +274,17 @@ protected State getState(SUT system) throws StateBuildException {
268274
&& system.get(Tags.PID, (long)-1) != (long)-1
269275
&& WinProcess.procName(system.get(Tags.PID)).contains("chrome")
270276
&& !WinProcess.isForeground(system.get(Tags.PID))){
271-
272-
WinProcess.toForeground(system.get(Tags.PID), 0.3, 100);
273-
LogSerialiser.log("Trying to set Chrome Browser to Foreground... "
274-
+ WinProcess.procName(system.get(Tags.PID)) + "\n");
275-
277+
278+
String msg = "Trying to set the browser to Foreground... " + system.get(Tags.PID, -1L);
279+
logger.log(org.apache.logging.log4j.Level.INFO, msg);
280+
281+
try {
282+
WinProcess.toForeground(system.get(Tags.PID), 0.3, 100);
283+
} catch (WinApiException wae) {
284+
logger.log(org.apache.logging.log4j.Level.WARN, wae);
285+
Verdict verdict = new Verdict(Verdict.Severity.NOT_RESPONDING, "Unable to bring the browser to foreground!");
286+
state.set(Tags.OracleVerdict, verdict);
287+
}
276288
}
277289

278290
return state;

0 commit comments

Comments
 (0)