SeleniumBase/examples/proxy_test.py

20 lines
712 B
Python
Raw Normal View History

from seleniumbase import BaseCase
2021-03-11 06:27:52 +08:00
class ProxyTests(BaseCase):
def test_proxy(self):
2021-05-06 09:06:24 +08:00
self.open("https://ipinfo.io/")
2022-04-18 13:28:14 +08:00
ip_address = self.get_text('#ip-string span[class*="primary"] span')
2019-08-06 13:39:32 +08:00
print("\n\nMy IP Address = %s\n" % ip_address)
print("Displaying Host Info:")
2022-04-18 13:28:14 +08:00
text = self.get_text("#widget-scrollable-container").split("asn:")[0]
2021-05-06 09:06:24 +08:00
rows = text.split("\n")
2021-02-25 15:34:07 +08:00
data = []
for row in rows:
if row.strip() != "":
data.append(row.strip())
2021-05-06 09:06:24 +08:00
print("\n".join(data).replace('\n"', " "))
2022-08-05 02:10:41 +08:00
if not self.headless:
print("\nThe browser will close automatically in 7 seconds...")
self.sleep(7)