SeleniumBase/examples/proxy_test.py

21 lines
677 B
Python
Raw Normal View History

import time
from seleniumbase import BaseCase
class MyTestClass(BaseCase):
def test_proxy(self):
self.open('https://ipinfo.io/')
2018-06-18 02:42:12 +08:00
ip_address = self.get_text("div.home-ip-details span.value")[1:-1]
2019-08-06 13:39:32 +08:00
print("\n\nMy IP Address = %s\n" % ip_address)
print("Displaying Host Info:")
2021-02-25 15:34:07 +08:00
text = self.get_text('div.home-ip-details').split('asn:')[0]
rows = text.split('\n')
data = []
for row in rows:
if row.strip() != "":
data.append(row.strip())
print("\n".join(data).replace('\n"', ' '))
print("\nThe browser will close automatically in 7 seconds...")
time.sleep(7)