Browser not opening using Selenium and Kora on Google Colab - python

The browser will not open with the "get" object while using Google Colab with Selenium and Kora. Here is my code:
from kora.selenium import wd
website = "https://www.espn.com"
wd.get(website)
It just returns "completed" and nothing happens. Any advice?

By the browser won't open, you mean that you are expecting a window to open?
Because if so, that's just not possible. It runs headless. You can't redirect the server's - that colab is hosted on - monitor image to yours.

Related

How to play a Youtube video in python

What modules should I use to make a Python script where Python gets the name of a video, opens up a Chrome window, opens Youtube and plays the first result. I've tried Youtube Data API but it's not for that kind of things.
You can use the subprocess to call a browser and run the url you request. With this minimal code you can ask for a website to go, and open in firefox. But you can use it as a bootstrap code for your application using chrome.
import subprocess
url = input('What site you would to go: ')
subprocess.Popen(['firefox',url])
Using this template, you can just change the code to ask for a youtube link. If you have firefox installed you can just run it.
from selenium import webdriver
# You could also use Chrome, I just default to Firefox
driver = webdriver.Firefox()
driver.get('URL within some quotes')
# And if you want full-screen, finish it off with
driver.maximize_window()
And boom, that's a really quick way to open a site. You need to pip install selenium, of course, but this is my preferred way. Just wanted to offer an additional option.

Selenium browser not loading python with extension

I have a problem with loading the browser in selenium. I can run my driver.get() when I'm not using an extension. When I am using an extension it is freezing on the google chrome white screen and I NEED to press the refresh button on the top left corner in order to load the page that I want. The extension is also loaded in the google chrome right top corner and I dont get an error message. It isn't going to the page that I want. I have changed the url's also but nothing is changing. I have both chromedriver as google chrome version 74. Im closing all the google chrome tasks from taskmanager and run the program but still not working.
What I have:
options = Options()
options.add_extension(r"C:\Users\x\OneDrive\Desktop\crxSolver.crx")
driver = webdriver.Chrome(r'C:\Users\x\OneDrive\Desktop\chromedriver.exe', options=options)
driver.get("https://yahoo.com")
Displaying what is happening

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)

Use existing open tab and url in Selenium py

Hi I'm trying to use Selenium python to use a url that is already open on Internet Explorer. I had a look around and not sure if this is possible.
The reason why I wouldn't like to open new brower or tab is because the page changes to different text.
So far my text only opens a new browser
CODE
from selenium import webdriver
driver = webdriver.Ie()
driver.get("https://outlook.live.com/owa/")
This answer helped me with same problem.
By now you can not access previously opened tabs with selenium.
But you can try to recreate your session, passing what is needed using requests library, for example.

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