-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Webdriver - syntax for changing 'page_load_strategy' #1820
Comments
@akozyreva I have a busy schedule for the next two hours but to try to get you immediate support, I think you may have the wrong options structure. .. ah looks like ChromeOptions is an instance of selenium.webdriver.chrome.options. (I'll admit i rarely use options in the testing I do so I am a bit ignorant in this area :) ) |
I do prefer the adding options via the string format over the method above as seen in the "Open Browser" keyword doc. Using the example there I would guess this should look like
with a question about quoting 'eager'. Not sure if that is need or not but am assuming it is expecting a string. The other question I have is how do you know, the implementation above is not working? |
Tried out some simple test cases. For both *** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Check Setting Page Load Strategy
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys,selenium.webdriver
${options.page_load_strategy}= Set Variable eager
Call Method ${chrome_options} add_argument ${options.page_load_strategy}
Create Webdriver Chrome chrome_options=${chrome_options}
Open Browser ${None} Chrome options=add_argument("page_load_strategy='eager'") with the log showing the request for just the
But if I make a small unit test case and add logging, as in import logging
import sys
root = logging.getLogger()
root.setLevel(logging.DEBUG)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
root.addHandler(handler)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.page_load_strategy = 'eager'
driver = webdriver.Chrome(options=options)
driver.get("http://www.google.com")
driver.quit() then the request going out has the page load strategy under the capabilities and desired capabilities structure
I will look to see what the library is doing internally with options and capabilities. |
I stepped through the code and see why it was doing what I observed above and figured out how to set the argument properly. The folowing works, *** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Check Setting Page Load Strategy
Open Browser ${None} Chrome options=page_load_strategy("eager") Noting the difference of this with what I tried above |
Similarly to do this under *** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Check Setting Page Load Strategy
${chrome_options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys,selenium.webdriver
${chrome_options.page_load_strategy}= Set Variable eager
Create Webdriver Chrome chrome_options=${chrome_options} |
Closing this issue as the above should allow one to set the page_load_strategy for either the |
Hi @emanlove ! Many thanks for your help! It works like a charm. P.S. Would be nice if it will be documented somewhere, e.g. in Manual. |
@akozyreva I went ahead an created an issue (#1842) to update the documentation hopefully making this more clear. Thanks for suggesting this! |
Additional information
Hi everyone! Could you please tell me, how can I change pageLoadStrategy, when use keyword create
Create Webdriver
with chromedriver?Expected behavior and actual behavior
I tried to change value of property
pageLoadStrategy
in the following way:But it doesn't work
Environment
Browser driver: ChromeDriver 111.0.5563.64
Operating System: MacOS
Libraries
The text was updated successfully, but these errors were encountered: