@@ -389,7 +389,6 @@ class TestTabNavigation:
389389 async def test_go_to_new_url (self , tab ):
390390 """Test navigating to a new URL."""
391391 tab ._connection_handler .execute_command .side_effect = [
392- {'result' : {'result' : {'value' : 'https://old-url.com' }}}, # current_url
393392 {'result' : {}}, # Page.enable
394393 {'result' : {'frameId' : 'frame-id' }}, # navigate command
395394 {'result' : {}}, # Page.disable
@@ -403,15 +402,14 @@ async def fire_callback(event_name, callback, temporary=False):
403402
404403 await tab .go_to ('https://example.com' )
405404
406- assert tab ._connection_handler .execute_command .call_count == 4
405+ assert tab ._connection_handler .execute_command .call_count == 3
407406
408407 @pytest .mark .asyncio
409408 async def test_go_to_navigation_error (self , tab ):
410409 """Test that navigation errors raise NavigationError."""
411410 from pydoll .exceptions import NavigationError
412411
413412 tab ._connection_handler .execute_command .side_effect = [
414- {'result' : {'result' : {'value' : 'https://old-url.com' }}}, # current_url
415413 {'result' : {}}, # Page.enable
416414 {'result' : {'frameId' : 'f' , 'errorText' : 'net::ERR_NAME_NOT_RESOLVED' }},
417415 {'result' : {}}, # Page.disable
@@ -431,11 +429,10 @@ async def fire_callback(event_name, callback, temporary=False):
431429
432430 @pytest .mark .asyncio
433431 async def test_go_to_same_url (self , tab ):
434- """Test navigating to the same URL (should refresh) ."""
432+ """Test navigating to the same URL works the same as a new URL ."""
435433 tab ._connection_handler .execute_command .side_effect = [
436- {'result' : {'result' : {'value' : 'https://example.com' }}}, # current_url
437434 {'result' : {}}, # Page.enable
438- {'result' : {}}, # refresh command
435+ {'result' : {'frameId' : 'frame-id' }}, # navigate command
439436 {'result' : {}}, # Page.disable
440437 ]
441438
@@ -447,13 +444,12 @@ async def fire_callback(event_name, callback, temporary=False):
447444
448445 await tab .go_to ('https://example.com' )
449446
450- assert tab ._connection_handler .execute_command .call_count == 4
447+ assert tab ._connection_handler .execute_command .call_count == 3
451448
452449 @pytest .mark .asyncio
453450 async def test_go_to_timeout (self , tab ):
454451 """Test navigation timeout."""
455452 tab ._connection_handler .execute_command .side_effect = [
456- {'result' : {'result' : {'value' : 'https://old-url.com' }}}, # current_url
457453 {'result' : {}}, # Page.enable
458454 {'result' : {'frameId' : 'frame-id' }}, # navigate command
459455 {'result' : {}}, # Page.disable
@@ -1851,38 +1847,6 @@ async def fire_callback(event_name, callback, temporary=False):
18511847
18521848 assert tab ._page_events_enabled is False
18531849
1854- @pytest .mark .asyncio
1855- async def test_refresh_if_url_not_changed_same_url (self , tab ):
1856- """Test _refresh_if_url_not_changed with same URL."""
1857- tab ._connection_handler .execute_command .side_effect = [
1858- {'result' : {'result' : {'value' : 'https://example.com' }}}, # current_url call
1859- {'result' : {}}, # Page.enable
1860- {'result' : {}}, # refresh call
1861- {'result' : {}}, # Page.disable
1862- ]
1863-
1864- async def fire_callback (event_name , callback , temporary = False ):
1865- callback ({'method' : event_name , 'params' : {}})
1866- return 1
1867-
1868- tab ._connection_handler .register_callback = AsyncMock (side_effect = fire_callback )
1869-
1870- result = await tab ._refresh_if_url_not_changed ('https://example.com' )
1871-
1872- assert result is True
1873- assert tab ._connection_handler .execute_command .call_count == 4
1874-
1875- @pytest .mark .asyncio
1876- async def test_refresh_if_url_not_changed_different_url (self , tab ):
1877- """Test _refresh_if_url_not_changed with different URL."""
1878- tab ._connection_handler .execute_command .return_value = {
1879- 'result' : {'result' : {'value' : 'https://different.com' }}
1880- }
1881-
1882- result = await tab ._refresh_if_url_not_changed ('https://example.com' )
1883-
1884- assert result is False
1885- assert_mock_called_at_least_once (tab ._connection_handler )
18861850
18871851
18881852class TestTabRequestManagement :
0 commit comments