I'm testing an web application with selenium, what I want to check is if there are calls done in the background (post,get). e.g. I load google.com and in the developer options I can see that it does some requests.
I looked into the documentation for the selenium library in Robot Framework but cant find an option. Is it possible to get the requests done? I also found selenium wire that does exactly what I want, but in all the examples they use a driver object, Is it possible to get the driver object used by Robot Framework/selenium?
e.g.
*** Settings ***
Documentation Simple example using SeleniumLibrary.
Library SeleniumLibrary
*** Variables ***
${LOGIN URL} http://localhost:7272
${BROWSER} Chrome
*** Test Cases ***
Valid Login
Open Browser To Login Page
Input Username demo
Input Password mode
Submit Credentials
Welcome Page Should Be Open
Get call to some-site should be done <---- what i want.
[Teardown] Close Browser
*** Keywords ***
Open Browser To Login Page
Open Browser ${LOGIN URL} ${BROWSER}
Title Should Be Login Page
Input Username
[Arguments] ${username}
Input Text username_field ${username}
Input Password
[Arguments] ${password}
Input Text password_field ${password}
Submit Credentials
Click Button login_button
Welcome Page Should Be Open
Title Should Be Welcome Page
I tried the following based on Bence Kaulics's answwer
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
def get_logs2(driver):
# enable browser logging
#d = DesiredCapabilities.CHROME
#d['goog:loggingPrefs'] = { 'browser':'ALL' }
#driver = webdriver.Chrome(desired_capabilities=d)
# load the desired webpage
#driver.get('http://34.90.50.21/')
#driver.get(driver.current_url)
a = driver.get_log('browser')
# print messages
for entry in driver.get_log('browser'):
print(entry)
print("finished")
return a
the robot part I do is:
*** Keywords ***
Get Logs2
[Arguments] ${arg1}
${seleniumlib}= Get Library Instance SeleniumLibrary
Log ${seleniumlib._drivers.active_drivers}[0]
Get Logs2 ${seleniumlib._drivers.active_drivers}[0]
But to no avail