I'm trying to translate webpage to English using python but not able to convert. can anyone please help me
options.add_argument("−−lang=es")
# # Create a new instance of the Chrome driver
driver = webdriver.Chrome(chrome_options=options)
I added the options but not working
Related
So I currently have code that works using chrome and webdrivermanager. However I was wondering if it is possible to convert the browser that Selenium uses from Chrome to Edge?
Is it as simple as a single line of code (redefining "driver" variable)? Or do I have to rewrite things completely?
The language is Python.
You must install Microsoft Edge WebDriver (https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/).
After that, you can use it like this :
driver = webdriver.Edge(r"path/msedgedriver.exe")
I'm trying to make a program that downloads pdfs after I've done a search. The web is an aspx and with selenium I can enter the information in the fields correctly:
input_user=driver.find_element(By.XPATH, '//*[#name="ctl00$SPWebPartManager1$g_93bc4c3a_0f69_4097_bed1_978c8b545335$freetext"]')
textolibre="jamaica"
input_user.send_keys(textolibre)
but the page that returns the results is the same (aspx) and I can't download the pdfs.
I would like to be able to enter the fields in the form without selenium opening a browser. I tried with PhantomJS but it says:
UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
And when you return the results, I can download them, considering that the url doesn't change.
While using PhantomJS just add 2 extra lines to your code
import warnings
warnings.filterwarnings("ignore")
Or else if you are using gekodriver for the firefox browser you can use this in your code
opts = webdriver.FirefoxOptions()
opts.headless = True
driver = webdriver.Firefox(options=opts, executable_path='Your gekdriver exe path')
If you could share a more detailed complete code i could help you more effeciently
I'm fairly new to programing and have been trying my best to get a grasp of different concepts. I've made a few games and twitter bots, and am looking at trying some web scraping/automation.
I have been following along with this tutorial https://www.youtube.com/watch?v=f7LEWxX4AVI
and have gotten stuck trying to enter text into the search bar. I'm using chrome Version 81.0.4044.129 and have the right Chromedriver to go with it.
This is my code from the tutorial -
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://youtube.com')
searchbox = driver.find_element_by_xpath('//*[#id="search"]')
searchbox.send_keys('Type Type Type')
searchButton = driver.find_element_by_xpath('//*[#id="search-icon-legacy"]')
searchButton.click()
It opens up chrome but does not enter anything into the search bar
📷
https://gyazo.com/68da5e2e2340265ae50125558ed8ed11
I get these errors that open in a new window
and I get these in my python shell
📷
https://gyazo.com/e9d702ef1ec4e4bc422ae537a3b59fbe
any advice would be very much appreciated.
I have the python piece of code which needs to be converted to Robot Framework.
Here is the python code..
chromeOptions = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "G:/"}
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "C:/Python27/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)
Is it possible to make it work in Robot Framework?
I don't have have much knowledge on Robot Framework.
Using Selenium2Library, a direct translation of that code would look like this:
${chromeOptions}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${prefs}= Create Dictionary download.default_directory G:/
Call Method ${chromeOptions} add_experimental_option prefs ${prefs}
${chromedriver}= Set Variable C:/Python27/chromedriver.exe
Create Webdriver Chrome chrome executable_path=${chromedriver} chrome_options=${chromeOptions}
Go To http://someurl/
[Teardown] Close All Browsers
This code depends on two library imports - Selenium2Library and Collections. It worked after adjusting your paths to my system.
Given that you know Python already, I'd direct you to any number of questions asking about how to implement Python in Robot Framework (that coding is mostly on the Python side). Much of the code could likely be simplified by the Open Browser keyword if all you want to do is open a new browser instance to a webpage. To change settings in Chrome, either refer to the questions that explain how to implement your Python code in Robot Framework or use ombre42's suggestions.
I want to read the InitialChatFriendsList from my Facebook profile with Selenium.
When I login into Facebook manually and display the page source I easily can find
the element. However, when I use Selenium I cannot find the string:
source = browser.page_source
print 'InitialChatFriendsList' in source
# False
Why I cannot find these Javascript elements?
I think you did not configure the javascript files in eclipse. So please remove all files java eclipse (selenium) files and configure the files newly.