1

My question is very simple. I am using Selenium in Python.

Selenium's default page loading strategy is waiting until the page loaded completely. I really like that, but I want to make my selenium not to wait for the page loading Just One Time.

I know there is a way to make the selenium driver object not to wait for the page loading, Eternally with desired capabilities.

capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"
driver = webdriver.Chrome(desired_capabilities=capa)
driver.get(URL)

But I want my driver to wait Only One Time. How can I do that? I've seen it is impossible to change the desired capabilities.

Of course, I need to use the same driver object because I have to control the window from the driver.

BPDESILVA
  • 2,040
  • 5
  • 15
  • 35
zenyatta
  • 97
  • 2
  • 9

2 Answers2

0

I don't get what you mean by "wait Only Once". However, because Chrome driver still does not support pageLoadStrategy = eager so you can try driver.implicitly_wait. There is a further explanation here so I will no go in details.

Similar question

Hope it helps.

Hùng Nguyễn
  • 599
  • 8
  • 24
0

I understand what you mean. You would like to change attributes of your driver after it has started. You can try this code.

capa = DesiredCapabilities.CHROME
capa["pageLoadStrategy"] = "none"
driver = webdriver.Chrome(desired_capabilities=capa)
driver.get(URL)
driver.desired_capabilities.update({'pageLoadStrategy':'normal'})
driver.get(URL)

When i printed the classes attributes, it definitely does change the load strategy while running. Although im not sure if it actually affects the behavior of the browser,since the attributes of the browser are created upon initialization of the driver.

Robert Kearns
  • 1,631
  • 1
  • 8
  • 15