Skip to content

Commit 6a22d09

Browse files
author
Vasyl Vavrychuk
committed
display session id
1 parent b1a21ea commit 6a22d09

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

web/WebDriverJsDemo.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131

132132
<div style="margin-top: 20px">
133133
<input type="submit" value="Quit" onclick="wd.onQuit()"/>
134+
<span id="sessionIdLabel" style="color: gray; float:right;"></span>
134135
</div>
135136
</body>
136137
</html>

web/webdriver-app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,15 @@ WebDriverJsView.prototype.updateSessionDepControls = function() {
542542
}
543543
}
544544

545+
WebDriverJsView.prototype.setSessionId = function(id) {
546+
var element = document.getElementById('sessionIdLabel');
547+
if (id != null) {
548+
element.innerHTML = 'Session: ' + id;
549+
} else {
550+
element.innerHTML = '';
551+
}
552+
}
553+
545554
WebDriverJsView.prototype.setFoundElementId = function(id) {
546555
var element = document.getElementById('foundElement');
547556
if (typeof id.ELEMENT === 'string') {
@@ -571,11 +580,16 @@ function WebDriverJsController() {
571580
}
572581

573582
WebDriverJsController.prototype.setServerUrl = function(serverUrl) {
583+
var self = this;
574584
this.driver.setServerUrl(serverUrl);
575585

576586
this.serverUrl = serverUrl;
577587
if (localStorage)
578588
localStorage.serverUrl = serverUrl;
589+
590+
this.driver.getSession().then(function(session) {
591+
self.view.setSessionId(session.getId());
592+
});
579593
}
580594

581595
WebDriverJsController.prototype.setWebPage = function(webPage) {
@@ -701,6 +715,7 @@ WebDriverJsController.prototype.onQuit = function() {
701715
this.visualizer.quit();
702716
this.webDriverUrlPort = null;
703717
this.webPage = null;
718+
this.view.setSessionId(null);
704719
};
705720

706721
WebDriverJsController.prototype.onWebDriverUrlPortChange = function() {

0 commit comments

Comments
 (0)