Class: NarouAgent::Actions::CreatePart
- Inherits:
-
NarouAgent::Action
- Object
- NarouAgent::Action
- NarouAgent::Actions::CreatePart
- Defined in:
- lib/narou_agent/actions/create_part.rb
Constant Summary
Constants included from UrlHelper
Instance Method Summary collapse
Methods inherited from NarouAgent::Action
Methods included from UrlHelper
Constructor Details
This class inherits a constructor from NarouAgent::Action
Instance Method Details
#run(ncode, subtitle, body, date = nil, wait_duration = NarouAgent::DEFAULT_WAIT_DURATION) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/narou_agent/actions/create_part.rb', line 4 def run(ncode, subtitle, body, date = nil, wait_duration = NarouAgent::DEFAULT_WAIT_DURATION) driver.get(new_part_url(ncode)) driver.find_element(name: 'novel').send_keys(body) driver.find_element(name: 'subtitle').send_keys(subtitle) if !date.nil? && date > Time.now driver.script " $('.hasDatepicker').datepicker('setDate', new Date('\#{date.strftime('%F')}'));\n JAVASCRIPT\n Selenium::WebDriver::Support::Select.new(driver.find_element(:name, 'hour')).select_by(:value, date.hour.to_s)\n end\n\n driver.find_element(css: '#ziwainput[value=\"\u6B21\u8A71\u6295\u7A3F[\u78BA\u8A8D]\"]').click\n driver.find_element(css: '#ziwainput[value=\"\u6B21\u8A71\u6295\u7A3F[\u5B9F\u884C]\"]').click\n\n driver.find_element(xpath: '//h2[text()=\"\u6B21\u8A71\u6295\u7A3F[\u5B8C\u4E86]\"]')\n\n sleep wait_duration\n\n driver.navigate.to(novel_url(ncode))\n driver.find_element(link: subtitle)['href']\nrescue Selenium::WebDriver::Error::WebDriverError => e\n raise ActionFailedError.new(e)\nend\n" |