For the below code I am getting error as "no element found" if download_field_name == "form :" if (download_link =~ /fileEntityId=\d+/) != nil #driver.find_element(:link, link_text).click puts @extension puts link_text driver.find_element(:link, link_text).click if [".pdf",".gif",".bmp",".tif",".jpeg",".jpg"].include?(@extension) end end ******************** =========================================== C:\Documents and Settings\My Documents\userdata\Ruby\Scripts>dwonloadv4 .rb .bmp Gaurav Kapoor BR.bmp .txt Timothy L. Casbeer W9.txt .bmp Jason Mattiace BR.bmp .docx Reimbursements.docx =========================================== Are the below text is culprit - "Gaurav Kapoor BR.bmp" - this is present in the webpage, but above code is saying not found.
on 2013-02-26 09:52
on 2013-02-26 11:04
You have 2 spaces in that link name. Also you're not doing any checks to ensure that the name you provide actually exists.
on 2013-02-26 13:17
I did check but for some of the files it is happening. Those are present in the webpage. But instead clicking throwing errors: here is the code: if download_field_name == "form :" if (download_link =~ /fileEntityId=\d+/) != nil #driver.find_element(:link, link_text).click puts @extension puts link_text begin driver.find_element(:link, link_text).click if [".docx",".doc",".pdf",".gif",".bmp",".tif",".jpeg",".jpg",".txt"].include?(@extension) rescue => e wbs.cells(rows,4).value = link_text raise end end end Yes, There is two spaces but How should I handle this on the page,as the webpage is read only. I am just downloading files which has the extensions match only. But above mentioned files are not only downloaded,whereas they present there.
on 2013-02-26 14:12
Don't know why - `driver.find_element(:link, link_text).click` not
worked when string within the `link_text` has more than one spaces
between words. But anyway workaround I found is :
link_text.squeeze!(" ").strip! # to remove multiple spaces
on 2013-02-26 14:17
If you want multiple spaces in HTML to be displayed as such, you need to use non-breaking spaces: " " in HTML.
on 2013-02-26 14:20
Joel Pearson wrote in post #1099119: > If you want multiple spaces in HTML to be displayed as such, you need to > use non-breaking spaces: " " in HTML. Didn't understand you. BTW link_text is the file names to be downloaded from the webpage. webpage is from third party. And I managed it by using `strip` and `squeeze`. Don't know why the `driver` couldn't find out with in between multiple spaces. Thanks
on 2013-02-26 14:22
This is a well known feature of HTML and has information available all over the internet. Here's one example: http://codes.codedigest.com/CodeDigest/76-Display-...
on 2013-02-26 15:18
Joel Pearson wrote in post #1099125: > This is a well known feature of HTML and has information available all > over the internet. Here's one example: > > http://codes.codedigest.com/CodeDigest/76-Display-... Thanks Joel :) for sharing the link for my self learning. :) Amway long days no see. :)
on 2013-03-04 14:21
You might want to look into this for dealing multiple spaces in your input: http://www.ruby-doc.org/core-2.0/String.html#metho...
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.