MCPcopy Index your code
hub / github.com/TestLeafInc/Simba / init

Method init

src/main/java/com/force/base/ProjectHooks.java:86–127  ·  view source on GitHub ↗

Will be invoked before once for every test case execution and a) will launch the browser based on config b) create reporting structure c) store login state (if configured) d) create context, page e) set default time out based on config f) maximize and load the given URL @author TestLeaf

()

Source from the content-addressed store, hash-verified

84 * @author TestLeaf
85 */
86 @BeforeMethod
87 public void init() {
88 try {
89 // Launch the browser (based on configuration) in head(less) mode (based on configuration)
90 setDriver(ConfigurationManager.configuration().browser(), ConfigurationManager.configuration().headless());
91
92 // Set the extent report node for the test
93 setNode();
94
95 // Default Settings
96 NewContextOptions newContext = new Browser.NewContextOptions()
97 .setIgnoreHTTPSErrors(true)
98 .setRecordVideoDir(Paths.get(folderName));
99
100 // Auto Login if enabled
101 if(ConfigurationManager.configuration().autoLogin()) {
102 newContext.setStorageStatePath(Paths.get("storage/login.json"));
103 }
104
105 // Store for Auto Login, Set the video recording ON using context
106 context.set(getDriver().newContext(newContext));
107
108 // Create a new page and assign to the thread local
109 page.set(getContext().newPage());
110
111 // Set the timeout based on the configuration
112 getPage().setDefaultTimeout(ConfigurationManager.configuration().timeout());
113
114 // enable Tracing
115 if(ConfigurationManager.configuration().enableTracing())
116 getContext().tracing().start(new Tracing.StartOptions().setName(testcaseName).setSnapshots(true).setTitle(testcaseName));
117
118 // Get the screen size and maximize
119 maximize();
120
121 // Load the page with URL based on configuration
122 navigate(ConfigurationManager.configuration().baseUrl());
123
124 } catch (Exception e) {
125 reportStep("The browser and/or the URL could not be loaded as expected", "fail");
126 }
127 }
128
129 @BeforeClass(alwaysRun = true)
130 public void startTestcaseReporting() {

Callers

nothing calls this directly

Calls 15

configurationMethod · 0.95
setDriverMethod · 0.80
browserMethod · 0.80
headlessMethod · 0.80
setNodeMethod · 0.80
getMethod · 0.80
autoLoginMethod · 0.80
getDriverMethod · 0.80
getContextMethod · 0.80
getPageMethod · 0.80
timeoutMethod · 0.80
enableTracingMethod · 0.80

Tested by

no test coverage detected