Capybara open an html file in my computer - testing

I have an html file in my computer and I want to open that file using Capybara to test it. Could you help me to solve this problem?
P/S: That html file is created automatically in my app. I do appreciate any idea helping me to solve this problem. Thanks :)
UPDATE:
Based on the capybara source code here, I found that I should use Capybara.current_session.driver.visit instead of page.visit. The problem is solved

I can confirm that the update to the question works (assuming the file is in the current directory):
filename = 'foo.html'
Capybara.current_session.driver.visit filename

If your file is located at /path/to/folder/file.html
Set Capybara.app to a folder containing this file:
Capybara.app = Rack::File.new('/path/to/folder')
and then
visit 'file.html'
should work for you
See also this gist for example

With simple relative file path I got errors:
Failure/Error: visit 'foo.html'
Selenium::WebDriver::Error::InvalidArgumentError:
invalid argument
I didn't want to switch Capybara.app to Rack::File and back, so I've tried this way and it works:
visit "file://#{__dir__}/foo.html"

Related

Uploading pdf file with cypress

I need to create automatic test that as part of the flow i need to upload pdf file in my main application.
But i didnt find a way to do that...
Thanks in advance !
Uploading file works in Cypress when target "input" element is of "type="file"
cy.get("#myFile").selectFile("cypress/fixtures/dummy.pdf")
where ID of the input of type file= #myFile" and path of pdf file="cypress/fixtures/dummy.pdf"
Please refer to Cypress Docs: https://docs.cypress.io/api/commands/selectfile

dompdf rendering complete html in 1 line

I have created pdf with simple p tags, table and img tags.
On live server its not working and on localhost its working well.
Please see both pdf files.
Can you please help me to fix this issue?
Thanks
https://github.com/dompdf/dompdf/files/2218526/localhost.pdf
https://github.com/dompdf/dompdf/files/2218527/livesite.pdf
I've faced the same problem. I solved it..
You just need to delete a file dompdf_font_family_cache.php. You may found this file under 'dompdf/lib/fonts/'
and let the renderer regenerate the cache.
Hope this helps.

Selenium Webdriver: Target url is not well formed

I have stored the URL in the excel file. I read the excel file and put the url in the java Properties. i retrieve the url from properties and try to launch it, but i get the error "Target URL  http://demo.guru99.com/V4/ is not well-formed." Please help.
Properties pInputOutPut= new Properties();
//here i have code to read the excel file and load the url to properties
_driver.get(pInputOutPut.getProperty("Url"));
I had it resolved by appending (http/https) prefixes to my URL which were missing when I encountered this error. Hope this helps!
Are you sure there aren't some special characters in your string that aren't visible? Microsoft products tend to add more than what is desired
This issue resolved by itself!!. I tried a couple of different urls it worked, then i switched back to my original url it worked too.

Selenium 2.0 - File Upload not working

I am unable to upload a file using selenium. I employ the below code:
Browser.FindElement(By.XPath(XPath)).SendKeys(path);
However, all that happens is that the file browse form comes up. The file does not get selected.
Does anyone know what I need to do to get this working, or a workaround? Many Thanks.
Refer to(saucelabs.com/resources/selenium-file-upload)
WebElement upload = driver.findElement(By.id("myfile"));
upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");
driver.findElement(By.id("submit")).click();
driver.findElement(By.tagName("img"));
Also make sure you have given the path correctly. For example if the file is in d:\abc\pqr.txt, then path needs to be given as
"d:\\abc\\pqr.txt"
Mark this as an answer if this answers your question.
If not, please post your query!
Regards,
Sakshi

How to access local css files in external HTML File

I load some external files form the web in webview, but now I won't to improve the loading time and save all css und images on device.
My folder is /Ressources/assets/themes/....
In html file I try everything from simply assets/... to file:///Ressources....
What is the right way?
Thank you!
we have to use prefix app://
For a example if you want to include style.css which is inside of folder mycss
app://mycss/style.css
You need to use the app:// prefix.
Try this will may help you
Was there ever a solution to this problem? I'm having it as well. I tried 4 methods of linking:
../css/style.css
/css/style.css
app://css/style.css
file:///css/style.css
app://Resources/css/style.css works for me.
Using 3.1.1.GA