I tried to write a script in python using selenium, that should automate uploading images to an image platform. However, the problem is, that the functionality for uploading pictures is only given, when you use a mobile browser (e.g. Safari on your iPhone). In a quick research, i found that selenium supports this, but as far as i understood it, this is only given if you emulate the device or connect a real device on your computer. Is there another way (maybe even another library?) for not having such an overhead (connecting or emulating the device), if you want to simulate an mobile browser using python?
We can perform Selenium testing without a browser. This is achieved by triggering the execution in a headless mode. The headless execution can decrease the utilization of key resources and is being adopted widely.
Yes. Selenium is used to automate web browsers. It is primarily used for cross-browser testing of web applications. Appium, on the other hand, is mainly used for automating tests for native, hybrid, and mobile web apps on mobile devices.
We can run Selenium (Firefox) webdriver without a GUI. This means that the execution has to be kicked in headless mode. The headless execution is popular now since it results in less consumption of resources. Firefox, without GUI, can be executed after we set the geckodriver path.
Passing correct user agent should do the trick. Example with mobile Chrome:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1')
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://www.google.com')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With