How to use get_current_url method in SeleniumBase

Best Python code snippet using SeleniumBase

get.py

Source:get.py Github

copy

Full Screen

...5alert_doc = inline("<script>window.alert()</script>")6frame_doc = inline("<p>frame")7one_frame_doc = inline("<iframe src='%s'></iframe>" % frame_doc)8two_frames_doc = inline("<iframe src='%s'></iframe>" % one_frame_doc)9def get_current_url(session):10 return session.transport.send(11 "GET", "session/{session_id}/url".format(**vars(session)))12def test_no_browsing_context(session, closed_window):13 response = get_current_url(session)14 assert_error(response, "no such window")15def test_get_current_url_matches_location(session):16 url = session.execute_script("return window.location.href")17 response = get_current_url(session)18 assert_success(response, url)19def test_get_current_url_payload(session):20 session.start()21 response = get_current_url(session)22 assert response.status == 20023 assert isinstance(response.body["value"], basestring)24def test_get_current_url_special_pages(session):25 session.url = "about:blank"26 response = get_current_url(session)27 assert_success(response, "about:blank")28def test_get_current_url_file_protocol(session, server_config):29 # tests that the browsing context remains the same30 # when navigated privileged documents31 path = server_config["doc_root"]32 if platform_name == "windows":33 # Convert the path into the format eg. /c:/foo/bar34 path = "/{}".format(path.replace("\\", "/"))35 url = u"file://{}".format(path)36 session.url = url37 response = get_current_url(session)38 if response.status == 200 and response.body['value'].endswith('/'):39 url += '/'40 assert_success(response, url)41# TODO(ato): Test for http:// and https:// protocols.42# We need to expose a fixture for accessing43# documents served by wptserve in order to test this.44def test_set_malformed_url(session):45 response = session.transport.send(46 "POST",47 "session/%s/url" % session.session_id, {"url": "foo"})48 assert_error(response, "invalid argument")49def test_get_current_url_after_modified_location(session):50 start = get_current_url(session)51 session.execute_script("window.location.href = 'about:blank#wd_test_modification'")52 Poll(session, message="URL did not change").until(53 lambda s: get_current_url(s).body["value"] != start.body["value"])54 response = get_current_url(session)55 assert_success(response, "about:blank#wd_test_modification")56def test_get_current_url_nested_browsing_context(session, create_frame):57 session.url = "about:blank#wd_from_within_frame"58 session.switch_frame(create_frame())59 response = get_current_url(session)60 assert_success(response, "about:blank#wd_from_within_frame")61def test_get_current_url_nested_browsing_contexts(session):62 session.url = two_frames_doc63 top_level_url = session.url64 outer_frame = session.find.css("iframe", all=False)65 session.switch_frame(outer_frame)66 inner_frame = session.find.css("iframe", all=False)67 session.switch_frame(inner_frame)68 response = get_current_url(session)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful