Class: CodeOnline::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/code_online/client.rb

Constant Summary collapse

HOMEPAGE_URL =
"https://codeonline.fr/dashboard/list".freeze
LOGIN_URL =
"https://codeonline.fr/login".freeze

Instance Method Summary collapse

Constructor Details

#initialize(email:, password:) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/code_online/client.rb', line 6

def initialize(email:, password:)
  @browser = ::Watir::Browser.new(:chrome, headless: true)

  (email: email, password: password)
end

Instance Method Details

#create_ean(product_name:, weight:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/code_online/client.rb', line 12

def create_ean(product_name:, weight:)
  browser.goto(HOMEPAGE_URL)
  browser.button(id: "button-basic").click
  browser.link(visible_text: "Créer un GTIN").click

  browser.radio(id: "choice_0").select
  browser.button(visible_text: "J'ai compris").click

  browser.span(visible_text: "Équipements de Marquage Sportif").click
  browser.text_field(id: "brand").set("Grinta")
  browser.text_field(id: "product-name-item-value-0").set(product_name)
  browser.text_field(id: "net-content-item-input-0").set(weight)
  browser.select(class: "net-content-item-unit").select("Gramme")
  browser.button(visible_text: "Suivant").click
  browser.button(visible_text: "Terminer et afficher la fiche produit").click

  browser.span(class: "gtixnValue").text
end