I know that it is possible to make Chrome work in Android phone using selenium.
Is there a way to do this with Microsoft Edge?
I have the next code in python.
from selenium import webdriver
import time
options = webdriver.Edge()
options.add_experimental_option("androidPackage", "com.android.edge")
driver = webdriver.Edge("./msedgedriver", options=options)
driver.get("https://bing.com")
time.sleep(100)
driver.quit()
# out => AttributeError: 'WebDriver' object has no attribute 'add_experimental_option'
It will launch Edge on the PC instead of on mobile.
CodePudding user response:
You have to import and configure options
for the Edge
driver properly.
I'm not sure about the androidPackage
specifically, but your code should be something like this:
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
edge_options = EdgeOptions()
edge_options.add_experimental_option("androidPackage", "com.android.edge")
driver = Edge(executable_path="./msedgedriver", options=edge_options)
driver.get("https://bing.com")
time.sleep(1000)
driver.quit()
CodePudding user response:
You should use webdriver.EdgeOptions() to define EdgeOptions instead of webdriver.Edge()
when using selenium webdriver.
And the relevant error has been mentioned in the code you provided:
'WebDriver' object has no attribute 'add_experimental_option'
Unfortunately I don't know much about Android development, but I'm sure that the webdriver.EdgeOptions() object can call the add_experimental_option
method.