Having no style in Chrome Webdriver (Selenium) as Firefox menu built function - python

I'm recently using selenium chrome webdriver to scrape some data of simple websites, now I'm targeting to lower the time it takes to open the page. I have found the list of parameters I can turn off in Chrome - link1, now I'm wondering what are the functions Mozilla Firefox automatically turns off when I simple click "no style" on the browser menu.
I sucessfully turned off images, but I think there are other things to disable.
prefs = {"profile.managed_default_content_settings.images":1,}
link1 : http://peter.sh/experiments/chromium-command-line-switches/#disable-application-cache
*** Edit: I have already tried PhantomJS, I have tested it and apearently it took more time to load pages than chrome.

Related

How do you stay logged in with the Selenium Chrome browser?

I use the following code to open a Chrome window using Selenium:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.youtube.com/")
However, whenever I enter the site, I am logged out. On other sites, I can manually do so, but Google deems it unsafe to log in with Selenium.
I know that Selenium is a test browser, but is it possible to stay logged in with Selenium so that I can access my user data; or is that not the purpose of Selenium, and calling the Chrome subprocess the way to go?
To start with Selenium isn't a browser as such but a bunch of libraries which helps in simulating Browsing Context.
From the question it's not that clear why you are logged out once you login in to the site. But definitely once you are logged in using Selenium driven ChromeDriver initiated google-chrome Browsing Context you must remain logged in and should be able to access your user data.

Python: How to automate 'Allow' flash player content in Firefox?

I need to allow flash content in an automated manner in Python. I tried using Selenium in Python to do so but could not manage. The issue is that browsers stopped supporting settings that always allow flash content. Moreover, the "Allow" button cannot be accessed via Selenium for instance because it is not a part of the website or a setting in Firefox. Does anyone know about a potential workaround?
Here is an image of the Firefox message that I need to somehow access:
"...The Allow button cannot be accessed via Selenium for instance because it is not a part of the website or a setting in Firefox. Does anyone know about a potential workaround?"
I don't know your OS but if it was my problem...
Try to find a "key press" module to send the A key press into Firefox (ie: the Allow shortcut).
Try to send a mouse-click at the coordinates of Allow button.
A good option to try is pyautogui. Once Flash is enabled by such module (clicker or presser) then you can involve Selenium for whatever you needed to do in the enabled Flash.
To allow flash content in an automated manner using Selenium through Python you need to use an instance of FirefoxProfile() and set_preference() method to configure:
dom.ipc.plugins.enabled.libflashplayer.so to true
plugin.state.flash to 2
Code Block:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
profile.set_preference("plugin.state.flash", 2)
driver = webdriver.Firefox(firefox_profile=profile, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

Selenium Web driver is not able to find the div class in Google Chrome webstore

I want to crawl some data from Google Chrome Website. But I am facing a problem whenever trying to use selenium webdriver. When I use following code I get an error stating that this element doesn't exist in the site.
button = driver.find_element_by_class_name("a-d-l-L")
Snapshot of the website:
And also, how to get data from a pop up window (this window comes up when I press a button). Following screen can be found on the next page. I want to store the data that is showing in the pop up message.
Google has special permissions on the Chrome Webstore, as of now you can't use Selenium to automate any page on the Chrome Webstore website.

Upload file using Selenium webdriver. Is there any crossbrowser solution?

Hi I am trying to figure out how to upload image by Selenium webdriver in python. Here is my code:
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.jpg")
It works well in Chrome, but not in other browsers. The problem is that it either opens OS native file browser or do nothing.
Is there any solution that works in all browsers? (I need Chrome, Firefox, IE, Edge)

Keys.ESCAPE in selenium webdriver(python)

I am using selenium webdriver (with python). I have a use case where I want to test that submit button get disabled once the form get submited. To test it, I send ESCAPE key to stop the page to load next page so that I can access the elements of same page.
password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE)
The problem is that it works fine in Firefox browser but it is not working in Chrome. In Chrome sending ESCAPE seems to be not working and it submits the form and loads the next page.
Is there any other solution or workaround to overcome this?
After trying many options, finally the following option seems to be working -
password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE) # this works for Firefox driver
drive.execute_script("window.stop();") # this works for Chrome driver
You can try one of these 3 suggestions from https://sqa.stackexchange.com/a/6208 :
Installing an extension in Chrome called Stop load
using the built in pageLoadTimeout() method in Selenium
using Sikuli or Autoit to access the browser's native controls

Categories

Resources