codejunky

Untitled

Apr 7th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. # Scenario 3
  2.  
  3. @given('on product creation popup')
  4. def step_on_add_new_product_popup(context):
  5.     # from time import sleep
  6.     # sleep(3)
  7.     elem = context.browser.find_element_by_id("add-new-product-title").is_displayed()
  8.     assert elem is True
  9.  
  10. @when (u'I fill the name field with {name}')
  11. def step_enter_product_name(context, name):
  12.     context.browser.find_element_by_id('product-name').send_keys(name)
  13.  
  14. @when(u'I fill the description field with {description}')
  15. def step_enter_product_(context, description):
  16.     context.browser.find_element_by_id('product-description').send_keys(description)
  17.  
  18.  
  19. @when(u'I fill the price field with {price}')
  20. def enter_password(context, price):
  21.     # context.browser.find_element_by_id('product-price').send_keys(price)
  22.     WebDriverWait(context.browser, 30).until(EC.presence_of_element_located((By.ID, "product-price"))).send_keys(price)
  23.  
  24. @when(u'I choose an {image} to upload')
  25. def enter_first(context, image):
  26.     context.browser.find_element_by_id('product-image').send_keys(image)
  27.  
  28. @when(u'I click on Add new product')
  29. def subscribe_click(context):
  30.     context.browser.find_element_by_id('add-submit').click()
  31.     # WebDriverWait(context.browser, 30).until(EC.presence_of_element_located((By.ID, "add-submit"))).click()
  32.  
  33. @then('product {name} should be displayed in the products table')
  34. def step_check_if_product_was_added_to_table(context, name):
  35.     # products_table = context.browser.find_elements_by_xpath("//td[contains(@class, 'bdd_class')]")
  36.     products_table = context.browser.find_elements_by_tag_name('td')
  37.     products_names = []
  38.  
  39.     for product in products_table:
  40.         products_names.append(product.text)
  41.  
  42.     print("This is it: ", products_names)
  43.  
  44.     assert_that(products_names, contains(name))
Add Comment
Please, Sign In to add comment