Skip to content

Commit 3899119

Browse files
Ankit098francisf
authored andcommitted
update: master with bstackdemo, local endpoint, W3C caps
1 parent c54d91e commit 3899119

File tree

7 files changed

+45
-30
lines changed

7 files changed

+45
-30
lines changed

config/local.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"key": "BROWSERSTACK_ACCESS_KEY",
44

55
"capabilities": {
6-
"build": "browserstack-build-1",
7-
"name": "BStack local behave",
8-
"browserstack.debug": true,
9-
"browserstack.local": true
6+
"bstack:options": {
7+
"buildName": "browserstack-build-1",
8+
"sessionName": "BStack local behave",
9+
"debug": true,
10+
"local": true
11+
}
1012
},
1113

1214
"environments": [{

config/parallel.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"key": "BROWSERSTACK_ACCESS_KEY",
44

55
"capabilities": {
6-
"build": "browserstack-build-1",
7-
"name": "BStack parallel behave",
8-
"browserstack.debug": true
6+
"bstack:options": {
7+
"buildName": "browserstack-build-1",
8+
"sessionName": "BStack parallel behave",
9+
"debug": true
10+
}
911
},
1012

1113
"environments": [{

config/single.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"key": "BROWSERSTACK_ACCESS_KEY",
44

55
"capabilities": {
6-
"build": "browserstack-build-1",
7-
"name": "BStack single behave",
8-
"browserstack.debug": true
6+
"bstack:options": {
7+
"buildName": "browserstack-build-1",
8+
"sessionName": "BStack single behave",
9+
"debug": true
10+
}
911
},
1012

1113
"environments": [{

features/environment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def before_feature(context, feature):
3434
if key not in desired_capabilities:
3535
desired_capabilities[key] = CONFIG["capabilities"][key]
3636

37-
if "browserstack.local" in desired_capabilities and desired_capabilities["browserstack.local"]:
37+
if "bstack:options" in desired_capabilities and "local" in desired_capabilities["bstack:options"] and desired_capabilities["bstack:options"]["local"]:
3838
start_local()
3939

4040
context.browser = webdriver.Remote(

features/local.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Feature: BrowserStack Local Testing
22
Scenario: can check tunnel working
3-
When visit url "http://bs-local.com:45691/check"
4-
Then page contains "Up and running"
3+
When visit url "http://bs-local.com:45454/"
4+
Then title contains "BrowserStack Local"

features/single.feature

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Feature: Google\'s Search Functionality
2-
Scenario: can find search results
3-
When visit url "http://www.google.com/ncr"
4-
When field with name "q" is given "BrowserStack"
5-
Then title becomes "BrowserStack - Google Search"
1+
Feature: BrowserStack Demo
2+
Scenario: Add product to cart
3+
When visit url "https://bstackdemo.com/"
4+
When item with xpath '//*[@id="1"]/p' is present to be added to cart
5+
When add to cart button '//*[@id="1"]/div[4]' for above item is clicked
6+
Then item in cart '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]' is same as the one which was added

features/steps/steps.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
import time
2+
from selenium.webdriver.common.by import By
23

34
@when('visit url "{url}"')
45
def step(context, url):
56
context.browser.get(url)
7+
time.sleep(2)
8+
9+
@when("item with xpath '{selector}' is present to be added to cart")
10+
def step(context, selector):
11+
item = context.browser.find_element(By.XPATH, selector)
12+
context.item_to_add = item.text
613

7-
@when('field with name "{selector}" is given "{value}"')
8-
def step(context, selector, value):
9-
elem = context.browser.find_element_by_name(selector)
10-
elem.send_keys(value)
11-
elem.submit()
12-
time.sleep(5)
14+
@when("add to cart button '{selector}' for above item is clicked")
15+
def step(context, selector):
16+
add_btn = context.browser.find_element(By.XPATH, selector)
17+
add_btn.click()
18+
time.sleep(2)
1319

14-
@then('title becomes "{title}"')
15-
def step(context, title):
16-
assert context.browser.title == title
20+
@then("item in cart '{selector}' is same as the one which was added")
21+
def step(context, selector):
22+
item = context.browser.find_element(By.XPATH, selector)
23+
item_in_cart = item.text
24+
assert item_in_cart == context.item_to_add
1725

18-
@then(u'page contains "{body}"')
19-
def step(context, body):
20-
assert body in context.browser.page_source
26+
@then('title contains "{title}"')
27+
def step(context, title):
28+
assert title in context.browser.title

0 commit comments

Comments
 (0)