Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Ruby
Posted by: Mandisi Makwakwa
Added: May 24, 2018 2:52 PM
Views: 13
Tags: no tags
  1. # Get Form Element Attribute
  2.           element_form = $driver.form(:id=>/uploadForm_/)
  3.           attribute_state = element_form.attribute_value('class')
  4.           p "Attribute State : #{attribute_state}"
  5.  
  6.           p "Executing JS..."
  7.           # Execute JS
  8.           script = "return arguments[0].removeAttribute('class')"
  9.           $driver.execute_script(script, element_form)
  10.  
  11.           # Get Input Element
  12.           puts "Checking that File Field Exists"
  13.           elem_file_field = $driver.file_field.exists?
  14.           if elem_file_field
  15.             puts "Setting File Field..."
  16.             $driver.file_field(:class=>'one').set file_path
  17.             # $driver.element(:class=>'one').send_keys(file_path)
  18.             # p element_form.element(:class=>'one').send_keys file_path
  19.             # p element_form.element(:class=>'one').set file_path
  20.             element_form.element(:class=>'one').click
  21.             puts "File Field has been Set..."
  22.           end
  23.  
  24.           # p "Sending Keys to File Path..."
  25.           # $driver.file_field(:name=>'file').set(file_path)
  26.  
  27.           # element_input.send_keys(file_path)
  28.  
  29.           # p "Clicking Upload Button..."
  30.           # $driver.element(:xpath=>'//*[@id="uploadForm_1527166589431"]/input[1]').click