Still new to a Python.
I need to be able to open a Chrome browser with specific profile.
And verify that proper the page is opened, by specific element on a page
Use selenium to control the browser from python.
https://selenium-python.readthedocs.io/getting-started.html#simple-usage
You can use the chrome driver that you download from https://chromedriver.chromium.org/downloads
You will use XPATH to locate the elements and validate the page
https://selenium-python.readthedocs.io/locating-elements.html
Related
the thing is I can login to the site only from one device, which is my browser so I can't use selenium, so I have to use something else which opens my browser and copy the text from an element using python.
I think that you may use one of two solutions:
use selenium to open a browser every time, and automate the login process.
If the site allows you to access without logging in when you access with your default browser(such as Stack Overflow for example - you don't need to login every time you open the website from your device), you can use the same browser profile and it should do the same job - login automatically to that website.
references:
what's a browser profile?
how to load a chrome's browser profile with python3 and selenium?
As it stands and I speak under correction, selenium opens a "private" browser tab.
I wanted to know if there was any way to change that so that the selenium tab can benefit from other tabs that are open, i.e. not need to login because you are already logged in on another non-selenium tab
I think the problem is that Selenium loads up the default browser profile. If you use chrome or a chromium based browser, go to chrome://version and you should see a heading called Profile Path copy that and add it to your program with the options method.
Here is a sample:
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=path_to_chrome_profile") #Path to your chrome profile
driver = webdriver.Chrome(executable_path="path_to_chromedriver", chrome_options=options)
Hope it helps. And yes, make sure you are signed into the account you want selenium to access when you check your path.
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.
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.
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