targetmy 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/targetmy/robot.rb +37 -49
- data/lib/targetmy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0967bc88564143ab5918246abfcb96660bcb853e
|
4
|
+
data.tar.gz: 9cd132406ad68c74b64c910f3b21cd432db79d00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e9938d430cb9db861129cb324cf951a1e063c8ec7256194feebee9cc80a9fb45f9ac8406544f08d032684cfec12cd4e25394d418698cb3bd7812ac2effb804
|
7
|
+
data.tar.gz: fa0e56486b09883d27ea95e1f3eea17b22a49b5beded01228a03f1300faa9480cfb088e80cc5b8683e08d2683031ef24ec3be16d2b4a0c541a574fe3dda07726
|
data/lib/targetmy/robot.rb
CHANGED
@@ -41,71 +41,59 @@ module Targetmy
|
|
41
41
|
@browser.goto CAMPAIGNS_URL
|
42
42
|
|
43
43
|
@config.items.each do |config|
|
44
|
-
|
45
|
-
|
44
|
+
# click to create_campaign_btn
|
45
|
+
Watir::Wait.until { @browser.link(:css, ".campaign-toolbar .campaign-toolbar__create-button").present? }
|
46
|
+
@browser.link(:css, ".campaign-toolbar .campaign-toolbar__create-button").click
|
46
47
|
|
48
|
+
# select product type and set link to the advertised site
|
49
|
+
Watir::Wait.until { @browser.div(:css, ".product-types.js-product-types-wrap").present? }
|
50
|
+
@adv_type_index = ADV_TYPES_INDEXES[config.type.to_sym]
|
51
|
+
@browser.div(css: ".product-types__item", index: @adv_type_index).click
|
52
|
+
@browser.text_field(:css, ".base-setting-my__main-url__input.js-main-url-input").set(config.link)
|
53
|
+
|
54
|
+
# setup adv_products
|
47
55
|
Watir::Wait.until { @browser.div(:css, ".js-pacs-wrapper").present? }
|
48
56
|
@adv_prod_index = nil
|
49
57
|
config.adv_products.each do |prod|
|
50
|
-
|
58
|
+
# select adv product
|
59
|
+
if @adv_prod_index != ADV_PROD_INDEXES[prod.type.to_sym]
|
60
|
+
@adv_prod_index = ADV_PROD_INDEXES[prod.type.to_sym]
|
61
|
+
@browser.div(css: ".pac-item._gray-block", index: @adv_prod_index).click
|
62
|
+
end
|
51
63
|
|
64
|
+
# create ads
|
52
65
|
Watir::Wait.until { @browser.div(:css, ".banner-form").present? }
|
53
66
|
prod.ads.each do |ad|
|
54
|
-
|
67
|
+
# set ad form fields
|
68
|
+
@browser.text_field(:css, ".banner-form__input.js-text-value").set(ad.title)
|
69
|
+
@browser.textarea(:css, ".banner-form__input.js-text-value.banner-form__input_text-area").set(ad.text)
|
70
|
+
@browser.file_field(:css, ".banner-form__img-file.banner-form__input.js-image-value").set(ad.image)
|
71
|
+
# handle crop image
|
72
|
+
Watir::Wait.until { @browser.button(:css, ".image-cropper__save").present? }
|
73
|
+
@browser.button(:css, ".image-cropper__save").click
|
74
|
+
|
75
|
+
# create ad click
|
76
|
+
Watir::Wait.until { @browser.button(:css, ".banner-form__save-button.js-banner-save").present? }
|
77
|
+
Watir::Wait.until { sleep 1 }
|
78
|
+
@browser.button(:css, ".banner-form__save-button.js-banner-save").click
|
55
79
|
end
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
80
|
+
|
81
|
+
# set another fields
|
82
|
+
@browser.text_field(:css, ".js-campaign-name").set(prod.campaign_name)
|
83
|
+
# click to the finish btn
|
84
|
+
@browser.div(:css, ".create-page__main-button").click
|
85
|
+
|
86
|
+
puts "finish"
|
61
87
|
end
|
62
88
|
|
63
89
|
end
|
64
90
|
|
65
|
-
|
91
|
+
rescue Exception => e
|
66
92
|
@browser.close
|
93
|
+
raise e
|
67
94
|
end
|
68
95
|
end
|
69
96
|
|
70
|
-
def set_campaign_name prod
|
71
|
-
@browser.text_field(:css, ".js-campaign-name").set(prod.campaign_name)
|
72
|
-
end
|
73
|
-
|
74
|
-
def click_finish_campaign_btn
|
75
|
-
@browser.div(:css, ".create-page__main-button").click
|
76
|
-
end
|
77
|
-
|
78
|
-
def create_ad ad
|
79
|
-
@browser.text_field(:css, ".banner-form__input.js-text-value").set(ad.title)
|
80
|
-
@browser.textarea(:css, ".banner-form__input.js-text-value.banner-form__input_text-area").set(ad.text)
|
81
|
-
@browser.file_field(:css, ".banner-form__img-file.banner-form__input.js-image-value").set(ad.image)
|
82
|
-
Watir::Wait.until { @browser.button(:css, ".image-cropper__save").present? }
|
83
|
-
@browser.button(:css, ".image-cropper__save").click
|
84
|
-
|
85
|
-
Watir::Wait.until { @browser.button(:css, ".banner-form__save-button.js-banner-save").present? }
|
86
|
-
Watir::Wait.until { sleep 1 }
|
87
|
-
@browser.button(:css, ".banner-form__save-button.js-banner-save").click
|
88
|
-
end
|
89
|
-
|
90
|
-
def click_product_btn prod
|
91
|
-
if @adv_prod_index != ADV_PROD_INDEXES[prod.type.to_sym]
|
92
|
-
@adv_prod_index = ADV_PROD_INDEXES[prod.type.to_sym]
|
93
|
-
@browser.div(css: ".pac-item._gray-block", index: @adv_prod_index).click
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def setup_adv_item config
|
98
|
-
Watir::Wait.until { @browser.div(:css, ".product-types.js-product-types-wrap").present? }
|
99
|
-
@adv_type_index = ADV_TYPES_INDEXES[config.type.to_sym]
|
100
|
-
@browser.div(css: ".product-types__item", index: @adv_type_index).click
|
101
|
-
@browser.text_field(:css, ".base-setting-my__main-url__input.js-main-url-input").set(config.link)
|
102
|
-
end
|
103
|
-
|
104
|
-
def click_create_campaign_btn
|
105
|
-
Watir::Wait.until { @browser.link(:css, ".campaign-toolbar .campaign-toolbar__create-button").present? }
|
106
|
-
@browser.link(:css, ".campaign-toolbar .campaign-toolbar__create-button").click
|
107
|
-
end
|
108
|
-
|
109
97
|
def login(email, password)
|
110
98
|
puts "login"
|
111
99
|
|
data/lib/targetmy/version.rb
CHANGED