Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
handle multiple selenium protocol versions for session-id (#164)
Browse files Browse the repository at this point in the history
handle multiple selenium protocol versions for session-id
  • Loading branch information
lanwen authored and vania-pooh committed Jul 21, 2019
1 parent 414e6ce commit b08087a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/src/containers/Capabilities/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ defer driver.Quit()
}
};

export const sessionIdFrom = (res) => {
return res.response.sessionId || (res.response.value && res.response.value.sessionId) || '';
};

class Capabilities extends Component {
static propTypes = {
state: PropTypes.object,
Expand Down Expand Up @@ -147,7 +151,7 @@ class Capabilities extends Component {
session.subscribe(
res => {
if (res.status === 200) {
this.props.history.push(`/sessions/${res.response.value.sessionId}`)
this.props.history.push(`/sessions/${sessionIdFrom(res)}`)
}
},
err => {
Expand Down
26 changes: 26 additions & 0 deletions ui/src/containers/Capabilities/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { sessionIdFrom } from "./index";

it('handles old selenium protocol versions', () => {
expect(sessionIdFrom({
response: {
sessionId: 'session-1'
}
})).toBe('session-1')
});

it('handles new selenium protocol versions', () => {
expect(sessionIdFrom({
response: {
value: {
sessionId: 'session-2'
}
}
})).toBe('session-2')
});

it('handles wrong response as empty', () => {
expect(sessionIdFrom({
response: {
}
})).toBe('')
});

0 comments on commit b08087a

Please sign in to comment.