Firefox Webdriver + installing plugin during the execution - webdriver

I am using Selenium Webdriver for Automation. Lately I have a need where I open a webpage, install a plugin(in the backend) and click a button. The button detects the installed plugin and lets me continue.
I can see this working in the normal firefox window. But somehow the WebDriver initiated firefox does not allow the same. The plugin is instantiated in the webpage and the button gets enabled.
I could install the plugin and see it in Add Ons page but the button is not getting enabled.
Is there a way I can force the webdriver to reload all the plugins or is there any security issue due to which webdriver is preventing the plug in from being instantiated?
Thanks in advance

If you want to use Add-on's mean you have to create a profile for Firefox and include add on's in that profile that is launched by the web driver applications. This will allow you to have access to the `Web Element' through add-on's. I am not sure how it will react. I didn't tried not yet. But this the way to use plug-in to the launched browser.
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1"); // Avoid tartup screen
WebDriver driver = new FirefoxDriver(firefoxProfile);
Reference from - http://code.google.com/p/selenium/wiki/FirefoxDriver

Related

CSS changes are not reflected even after changing version, hard refresh and clearing cache

I have an Angular application with CSS in it.I have recently changed the CSS and deployed it on server but it is not getting reflected in the client machines.
I have done the following things:
Clear cache and did a hard refresh (Ctrl+f5).
Changed the version number of the CSS file and redeployed it.
Opened developer tools and disabled Cache and reloaded.
Pressed F12, go to source and checked the CSS file if new changes are getting loaded. New changes are there.
When I opened the web application in a new machine, the new changes are getting reflected.
When can be the possible reason for CSS not getting reflected even after checking all the above. Is there anything which I'm missing?
is it a PWA (progressive web app)... ? in which case the data is served by service worker and not freshly fetched.
Go to
Chrome developer tools (press F12)...
Click on Application tab on
the left navigation, click on "Service workers" and 'unregister"
service workers...
going on the next option in the left navigation, click on "Clear storage"...
click on the "Clear site data" button on the right zone restart Chrome and check with Ctrl+shift+R
if you're using a CDN, you may have to purge the cache for this particular CSS file from there as well.
Make hard refresh (Ctrl+Shift+R)
or go to view page source and the open css file from it and make it refresh and then again make hard refresh...Your problem will be solved
Please clear the browser history of the application complete from begin and perform hard refresh and then try to login to your application
You can disable cache in development tool in chrome.
Go to Developer tool in Chrome by pressing F12, Network-> click on Disable Cache
I faced similar issue. This helped me. Hope it might help some one

JavaFX WebView, reCaptcha wont work (unsupported Browser)

Im trying to Code a Programm with a WebView with includes reCaptcha by Google. When i load the Web Page it says that my Browser doesnt Support reCaptcha. Is there anyway to fix this with a method or something?
Thanks!
Override user by overriding the User agent string using WebEngine.setUserAgent("use required / intended UA string");
There are a lot of issues with this:
In order to use a ReCaptcha, you need to have an HTTP/HTTPS environment, so you cannot serve the local file statically from WebView. This means that you'll have to either host your page online or on localhost and then open that within WebView.
As Priyanka mentioned, you can also override the user agent string as said, but the WebView browser still doesn't have all the JS libraries that you need (as of 2020, the "click all squares that have traffic lights" isn't functional).
I would probably recommend opening the auth page in the user's local browser and then using some kind of callback function.

How to enable cookies in Chromedriver with Webdriver?

I am trying to use Selenium's Chromedriver to log in to a website which has cookies enabled. I got a message from the server that the browser has cookies disabled. How can I enable cookies in Chromedriver?
ChromeDriver has cookie be enabled by default.
Please try the following steps:
Use FirefoxDriver/IEDriver, see what the site says.
Manually open a Chrome browser, see what the site says.
Try open whatismybrowser.com with ChromeDriver opened browser, see what it tells you.
If your site says cookie not enabled for FirefoxDriver/IEDriver/Manually opened Chrome, and whatismybrowser.com says your ChromeDriver opened browser has cookie enabled, then clearly something is wrong with your site, please try debug your site.
What I did to use an instance of Chrome with Selenium where I was logged in was to run the following Python code, which opens a new instance of Chrome.
If you already had Chrome open on your computer this will be a different instance of Chrome and you may see the Chrome app open in two different instances. With this new instance open I logged in to my account manually, then quit the new Chrome instance and ran the code again and then I was logged in.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
url = "urlToWebsiteToLogin"
chrome_options = Options()
chrome_options.add_argument("user-data-dir=/Users/username/Library/Application Support/Google/Chrome/Default") #path for MacOS
chrome_options.add_experimental_option("detach", True) #prevent window from closing
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(url)
Remember to quit the Chrome instance before running the code again or you will get the following error:
invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

How to set Flex application to open in browser windows

It's realy a silly question but I don't want to waste time looking for it.
The things is, I've build an application in flex which suppose to be for web but when I'm running it through the Flash builder, it opens up flash player app instead of openning in a web browser. I've tried to do "run as webapplication" but failed.
What should I do?
Thanks.
Most likely you do not have a browser set up in Flash Builder; but rather have it specified to use the setand alone player.
Bring up Window => preferences and type Browser. You'll see "General => Web browser" . What is selected? Are any web browsers installed on your machine listed there?
You can add new browsers by selecting the "new" button and providing the location of the executable file which launches the browser.
Configure your debug configuration in order to launch html with your swf, but not swf itself: Run -> Debug Configurations -> URL or path to launch.
You can write html page yourself (alternatively - specify URL of your site), or you can set up autogenerating: Project -> Properties -> Flex Compiler -> Generate HTML wrapper file. After the last one your debug configuration will be changed automatically.

Open a new browser window, or set focus to an existing browser

I'm using code similar to the following:
http://blog.flexexamples.com/2007/08/29/launching-new-browser-windows-from-flex/
I have a Flex app running in AIR, and when I click on a URL it opens a new tab in my existing browser. In addition to this the focus doesn't set to the browser. What this means is that I'm not aware of the URL opening in the browser unless I actually change focus from the app to the browser.
Is it possible to open a brand new spanking browser, or change focus to the browser so its really obvious to the user?
Thanks.
There is nothing you can do in AIR / Flex to make this happen. The behavior your seeing is due to operating system and browser settings. In AIR, navigateToURL just passes the URLtot he OS which handles the URL based on defaults.
If memory serves me, my firefox install ued to open in a new tab by default, but there was some setting I used to make it always open in a new window. Quick googling did not provide me the answer, though.

Resources