Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Where and how to post result to test case,retrieve Run Id and Case Id for Testrail API(automation)


#1

Dear All,

May I know how can I retrieve the Run_ID and Test_ID properly? I need to use it on my TestRail API send_post method.

My code as below:

require 'selenium-webdriver’
require ‘./testrail.rb’

client = TestRail::APIClient.new(‘xxx.xxx.xx.xxx/testrail’)
client.user = ‘.com’
client.password = '

#I’m not very sure how to use get_run
#c = client.get_run()
#puts c

#Firefox browser instantiation
driver = Selenium::WebDriver.for :firefox

#Loading the assertselenium URL
driver.navigate.to "xxxxxxxxxxx"
puts “Successfully navigated to Google page”

#Saving screenshot of the page
driver.save_screenshot("/usr/local/rvm/snapshots/google.png")

#Code below caused the errors
r = client.send_post(
‘add_result_for_case/3/6’,
{ :status_id => 1, :comment => ‘This test worked fine!’ }
)

puts r

But I end up got the errors as below:

/usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1570:in addr_port': undefined method+’ for nil:NilClass (NoMethodError)
from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1503:in begin_transport' from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1442:intransport_request’
from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1416:in request' from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1409:inblock in request’
from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:877:in start' from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1407:inrequest’
from /usr/local/rvm/scripts/testrail.rb:82:in _send_request' from /usr/local/rvm/scripts/testrail.rb:62:insend_post’
from sample1.rb:19:in `’

Please advice and prefer a more detailed steps-by-steps guide on how to do it properly and sorry for these simple question, I’m still a beginner. Thank you.

Best Regards,
Jerome


#2

Solved. Put Http instead of Https.


#3

Hi Jerome,

Thanks for the update, and glad to hear you were able to get this working! Just let us know in case you have any additional questions and we’re happy to help!

Regards,
Marco