This is my code for drop down selection using ruby:
ruby version is 2.4.3
watir version 6.8.4
cucumber version 3.01
firefox version 47
b.select(id: 'curLocation').option(text: 'Chennai').select
This code is not working for me.
require 'watir'
b = Watir::Browser.start 'bit.ly/watir-webdriver-demo'
s = b.select_list id: 'entry_1000001'
s.select'Ruby'
s.selected_options
Reference: watir
select_from_list = browser.select_list(:xpath, "xpath")
.option(:text => opts[:yourjson])
select_from_list.select
Its for example.
I hope it will help you
Exactly - you can use .option(:xpath, "xpath")
or .option(code: "xpath")
You are using #select wrong. Take a look at the specs for more examples, but all you have to do is:
b.select(id: 'curLocation').select('Chennai')
Also, Firefox 47 isn't a supported version any longer. Please update to the latest version of Firefox, and the latest geckodriver. Also your title says Watir 6.8.4, but you list 5.1.4, which is deprecated.
Related
Please help me, how to use Flowbite and Turbo Rails 7 with import map?
I use Flowbite v.1.5.3 as here https://flowbite.com/docs/getting-started/rails/
and tailwindcss
I found it https://github.com/themesberg/flowbite/issues/88 and i change "DOMContentLoaded" on "turbo:load" in dist/flowbite.js and in vendor/javascript/flowbite.js, but it's not work for me, my scripts work only if reload page
Good news, version 1.5.5 fixed the problem, just replace the old flowbite line in the importmap.rb with.
pin "flowbite", to: "https://unpkg.com/flowbite#1.5.5/dist/flowbite.turbo.js"
And remove this line if you added it.
Turbo.session.drive = false
I'm using JetBrains Rubymine for developing Rails applications. It's a great IDE but unfortunately I didn't find how to format the hTML or Ruby code.
Any suggestiongs?
Ctrl + Alt + I for Auto-indent line(s)
For more keymaps.
In OS X keymap try this one: ⌘+Alt+L
Code | Reformat Code... (Ctrl+Alt+L in Windows default keymap).
I am using Watir with Ruby on Rails.
I need to save screenshots of couple of pages using Watir. I have managed to get the page that I want to open to show in a browser, but cannot save the screenshot yet. Here's my code:
#browser = Watir::Safari.new
folios_screenshot_path = Rails.root.join('screenshots/')
#page = Page.find(5)
cur_url = root_url + 'pages/' + #page.id.to_s
#browser.goto cur_url
#browser.div(:id => "page").wait_until_present
#browser.driver.save_screenshot(pagess_screenshot_path + '/' + #page.id.to_s + '.png')
#browser.close
In the page that I load, there's a div element with id 'page', and I am trying to make Watir wait till that element is loaded in the Watir browser. But in my main browser, I get the error Unable to load page within 10 seconds, and the screenshot doesn't get saved either. Any idea on what's wrong?
There are several watir gems: watir (drives IE on windows), safariwatir (drives safari on mac), watir-webdriver (drives all popular browsers except safari on all popular operating systems).
You are using safariwatir gem, but you are trying to save screenshot using watir-webdriver's driver.save_screenshot. I would suggest that you take a screen shot with Firefox.
Just install watir-webdriver gem and change
#browser = Watir::Safari.new
to
#browser = Watir::Browser.new :ff
For more information, read free version of my Watir book:
https://github.com/zeljkofilipin/watirbook/downloads
Try following browser class, it works for me.
Browser::BROWSER.driver.save_screenshot(screenshot)
(reference)
I am developing a rails application using PDFKit.
I need to shrink the output into one page.
So I passed --disable-smart-shrinking=>false. (I tried --enable-smart-shrinking=>true but it doesn't make difference)
PDFKit.configure do |config|
config.wkhtmltopdf = "/some/path/wkhtmltopdf"
config.default_options = {
:encoding=>"UTF-8",
:page_size=>"Letter",
:margin_top=>"0.25in",
:margin_right=>"0.5in",
:margin_bottom=>"0.25in",
:margin_left=>"0.5in",
:disable_smart_shrinking=>false
}
end
Shrinking works on my dev machine(OS X) but doesn't on the production server (Linux).
Version 0.11.0 rc1 on the linux doesn't shrink.
Version 0.9.9 on my OS X shrinks.
Can you help me with it?
Thanks.
Sam
Some options (including the one you mentioned) only work with a patched version of QT. http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf-0.9.9-doc.html Unfortunately I don't know any more than that, but it should get you in the right direction.
I wanted to create PDFs for my rails application using wkhtml2pdf and wicked_pdf.
I downloaded and extracted wkhtml2pdf beta 4 and placed it in /usr/local/bin/wkhtml2pdf
I tried running it on a web site and it gave a nice result.
In my rails application (2.3.4) I installed wicked_pdf:
script/plugin install git://github.com/mileszs/wicked_pdf.git
script/generate wicked_pdf
Everything seemed to be ok.
inside script/console I run the following - (with the following output)
wp = WickedPdf.new
=># WickedPdf:0xb62f2c70 #exe_path="/usr/local/bin/wkhtmltopdf"
HTML_DOCUMENT = "<html><body>Hello World</body></html>"
=> "<html><body>Hello World</body></html>"
pdf = wp.pdf_from_string HTML_DOCUMENT
=> "/usr/local/bin/wkhtmltopdf - - -q"
=> "\n\n\n\n\n\n\n\n\n\n"
of course this isn't good. According to the test the result of my last command should start with "%pdf-1.4"
Any idea what I can do?
Having the same problem. Removed the -q option from the wicked_pdf.rb file on line 19 and then was able to get the proper string on the console.
=> "%PDF-1.4\n1 0 obj\n<<\n/Title ...
This also seems to have solved other problems. The PDF still didn't render correctly when using it from the web site - embedded font issue - on to the next issue now.
Hopefully this will work for you.