While on a scrapy shell, when I try to use the view(response) function, instead of opening a browser, it opens Visual Studio Code. How to make it open on a browser?
I read that webbrowser is the library used to view the page and that I could set the BROWSER variable to change its default. On a Linux Mint system, to which value should I change the BROWSER variable to in order to make the view command to open firefox?
Found the answer myself after some further searching.
The value of the BROWSER variable should be /usr/bin/firefox.
So, in my case, adding the following line to my ~/.bashrc file did the trick:
export BROWSER=/usr/bin/firefox.
Related
Is there any way to upload a file using rebot framework without tag and with the headless mode activated. I tried to use AutoIt and sikuliLibrary but they are not working .
best Regards
If you have an input element, you can use Choose File keyword :
Choose File id=input_id C://document/file.txt
Check the documentation : https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Choose%20File
You can upload the file with Selenium by sending the file you want to upload to a special file.
This will work regardless to the headless or regular Selenium mode.
With Python language syntax it will be:
driver.find_element_by_xpath("//input[#type='file']").send_keys("the_full_path_to_your_file")
With other languages it will be similar, just with some syntax changes.
I have to automate a scenario like a upload an image from windows explorer to TinyMCE component using Selenium. Since Selenium does not support OS control, I used AutoIt to upload the image.
AutiIt sets the image path to "File name" and seems like it clicks on 'Open' button as well. But the image is not loading to my "source" field.
Here is my Selenium command:
Runtime.getRuntime().exec("C:/XXXXX/src/test/resources/uploadImage.exe");
// Path of the AutoIT script file
AutoIT script:
WinActivate("Open")
Send("C:\LCNGProjects\Screenshots\Images\GifImage1.gif")
Sleep(5000)
Send("{ENTER}")
Refer the attached screenshot
Not sure if I have got the questions correct, Did you compile the script.
Can you please go through link below for script compilation and step by step info how to upload a file.
https://www.guru99.com/use-autoit-selenium.html
You do not need to use AutoIt. Auto will make your script dependable on windows machine only.
Instead of it find element using locator(i.e. xpath) of upload button which is having tag as type="file". Now pass this simple sendKeys with absolute path of your image in your machine like below:-
button2.sendKeys("C:\\UsersDesktop\\logo\\Summit-Logo-900px.png");
Or use
System.getProperty("user.dir"));
Append the path of file exluding your project path and filename inside your project
Example :-
button.sendKeys(System.getProperty("user.dir")+"\\logo\\Summit-Logo-900px.png");
below link contains more option to upload file like below :-
Using SendKeys command.
Using AutoIt scripting.
Using Jacob com interface.
http://www.techbeamers.com/handle-file-upload-selenium-webdriver/#h3
Hope it will help you :)
I'm not going to add full source code here. You can call the AutoIT script using this command inside your test case.
// Call to AutoIT script to upload the image
Runtime.getRuntime().exec("C:\\xxxxx\\src\\test\\resources\\uploadImage.exe");
AutoIT Scrip
ControlFocus("Open","","Edit1")
ControlSetText("Open","","Edit1","C:\xxxx\Images\jpgImage")
ControlClick("Open","","Button1")
For more information refer the following link
https://www.guru99.com/use-autoit-selenium.html
another one I cannot seem to find. But in vb.net, how do I force a new instance of IE or Chrome when clicking a button?
I may have already existing windows open, but I want to make it where when I click my button, it opens either Chrome, IE, etc. open new instance.
Is this even possible? Thanks!
The exe's should be in path so you can just run them like this
Process.Start("chrome.exe", "--new-window http://www.bing.com")
Process.Start("iexplore.exe", "http://www.bing.com")
If they aren't in path, you'll need to provide the full path to the exe, like c:\program files\internet explorer\iexplore.exe
By default on my system chrome opens up a new tab if you run chrome.exe without the --new-window parameter. When I run iexplore.exe, it always opens up a new window by default.
I'm running Intellij 13 Ultimate. I'm trying to open a web page I'm working on, and it's opened from the file system:
file:///Users/<username>/dev/index.html
Instead of something like:
http://localhost:<port>/index.html
Thing is, other projects run as expected and I can't figure out what's misconfigured in this specific project.
How do you open the page?
If you open your HTML file inside IntelliJ and go to Run > Run xxx.html (or Debug), a localhost page should be opened. If it isn't, check your Run Configuration (Run > Edit Configurations) and check the URL field.
View > Open in Browser should also work as expected.
I want to view the HTML source of a web page, I've using ICSharpCode.TextEditor, Scintilla,... and they're all good. But, I have missed Firefox HTML source viewer.
I wonder if I can use Mozilla ActiveX Control to open the source viewer or is there a command line argument that make Firefox open it? Thanks!
You can do that from the command line like:
$> firefox view-source:http://stackoverflow.com
Or you can put something like this in the URL bar: "view-source:http://stackoverflow.com"
If you happen to want to open it in a new window:
$> firefox -new-window view-source:http://stackoverflow.com
There is a reference at mozillazine.org.