diff --git a/lib/apress/selenium_eti/spec/company_site/eti/product_creation_spec.rb b/lib/apress/selenium_eti/spec/company_site/eti/product_creation_spec.rb index 791c129..97f9bfb 100644 --- a/lib/apress/selenium_eti/spec/company_site/eti/product_creation_spec.rb +++ b/lib/apress/selenium_eti/spec/company_site/eti/product_creation_spec.rb @@ -65,11 +65,6 @@ @product = { name: Faker::Name.title, rubric: CONFIG['eti']['rubric'], - portal_traits: { - gost: CONFIG['eti']['portal_traits']['gost'], - condition: CONFIG['eti']['portal_traits']['condition'], - manufacturer_country: CONFIG['eti']['portal_traits']['manufacturer_country'] - }, exists: CONFIG['eti']['exists']['in stock'], short_description: CONFIG['product_creation']['short_description']['valid'], description: 'description', @@ -77,24 +72,30 @@ wholesale_price: {wholesale_price: Faker::Number.number(2), wholesale_number: Faker::Number.number(2)} } - @cs_eti_page.create_and_set_product_fields(@product) + @portal_traits = { + trait_1: CONFIG['eti']['portal_traits']['trait_value_1'], + trait_2: CONFIG['eti']['portal_traits']['trait_value_2'] + } + @cs_eti_page.create_and_set_product_fields(@product) + @cs_eti_page.refresh @cs_eti_page.search_product(@product[:name]) + @cs_eti_page.set_portal_traits(@product[:name], @portal_traits) @cs_eti_page.copy_product(@product[:name]) @cs_eti_page.refresh @cs_eti_page.search_product(@product[:name]) + @cs_eti_page.wait_saving end - # TODO: поправить удаление - # after(:all) { 2.times { cs_eti_page.delete_product(@product[:name])} } - it 'отобразится 2 идентичных товара' do @first_product = @cs_eti_page.product_rows_elements[0].text expect(@cs_eti_page.product_rows_elements.length).to eq 2 expect(@cs_eti_page.product_rows_elements[1].text).to eq @first_product end + + after(:all) { 2.times { @cs_eti_page.delete_product(@product[:name]) } } end end end diff --git a/lib/pages/company_site/eti_page.rb b/lib/pages/company_site/eti_page.rb index 23a9179..6161ce2 100644 --- a/lib/pages/company_site/eti_page.rb +++ b/lib/pages/company_site/eti_page.rb @@ -20,7 +20,6 @@ class EtiPage < Page span(:price_cell, xpath: "//*[contains(text(), 'Указать розничную цену')]") span(:wholesale_price_cell, css: '.js-eti-wholesaleprice .bp-price-free') span(:exist_cell, xpath: "//*[contains(text(), 'Указать наличие')]") - span(:portal_traits_cell, css: '.js-eti-traits-edit') button(:add_product, css: '.new.js-add-product') text_area(:edit_text_area, css: '.edit-text') @@ -35,9 +34,6 @@ class EtiPage < Page text_area(:description, css: '.cke_textarea_inline') text_area(:wholesale_price, css: '.js-wholesale-price') text_area(:wholesale_number, css: '.js-wholesale-min-qty') - text_area(:gost, xpath: "//input[@data-name='ГОСТ']") - text_area(:condition, xpath: "//input[@data-name='Состояние']") - text_area(:manufacturer_country, xpath: "//input[@data-name='Страна-производитель']") button(:save_price, css: '.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only') span(:price_value, css: '.bp-price.fsn') @@ -234,12 +230,15 @@ def set_description(text) wait_saving end - def set_portal_traits(options = {}) - Page.link(:gost_link, xpath: "//a[text()='#{options.fetch(:gost, '')}']") - Page.link(:condition_link, xpath: "//a[text()='#{options.fetch(:condition, '')}']") - Page.link(:manufacturer_country_link, xpath: "//a[text()='#{options.fetch(:manufacturer_country, '')}']") + def set_portal_traits(name, options = {}) + Page.text_area(:trait_1, xpath: "//input[@data-name='#{CONFIG['eti']['portal_traits']['trait_1']}']") + Page.text_area(:trait_2, xpath: "//input[@data-name='#{CONFIG['eti']['portal_traits']['trait_2']}']") + Page.link(:trait_link1, xpath: "//a[text()='#{options.fetch(:trait_1, '')}']") + Page.link(:trait_link2, xpath: "//a[text()='#{options.fetch(:trait_2, '')}']") + Page.span(:portal_traits_cell, xpath: + "//td[@data-text='#{name}']/..//*[contains(text(), 'указать характеристики')]") - wait_until { portal_traits_cell_element.text.include?('указать характеристики') } + wait_until { portal_traits_cell? } browser .action @@ -247,17 +246,13 @@ def set_portal_traits(options = {}) .click .perform - self.gost = options.fetch(:gost, '') - wait_until { gost_link? } - gost_link + self.trait_1 = options.fetch(:trait_1, '') + wait_until { trait_link1? } + trait_link1 - self.condition = options.fetch(:condition, '') - wait_until { condition_link? } - condition_link - - self.manufacturer_country = options.fetch(:manufacturer_country, '') - wait_until { manufacturer_country_link? } - manufacturer_country_link + self.trait_2 = options.fetch(:trait_2, '') + wait_until { trait_link2? } + trait_link2 save_portal_traits wait_saving