Selfriver.session_id bietet eine falsche Sauce Labs -Sitzungs -IDPython

Python-Programme
Anonymous
 Selfriver.session_id bietet eine falsche Sauce Labs -Sitzungs -ID

Post by Anonymous »

Ich versuche, die session_id zu erhalten.

Code: Select all

    def test_sauce_link(self):
main_page_1 = MainPage(self.driver)
session_id = self.driver.session_id
clean_session_id = re.sub(r"-", "", session_id)
report_url = f"https://app.eu-central-1.saucelabs.com/tests/{clean_session_id}"
TelegramReport.send_tg(f"{report_url}")
The resulting ID from the run log:
Message sent to Telegram:
https://app.eu-central-1.saucelabs.com/ ... e237e42ebe
Meanwhile, the actual link from Sauce Labs sind:
https://app.eu-central-1.saucelabs.com/ ... ed389562d2
Adbr/>
Meine Basisklasse mit Kappen: < /p>

Code: Select all

class BaseTest(unittest.TestCase):
SAUCE_URL = "https://ondemand.eu-central-1.saucelabs.com:443/wd/hub"

def setUp(self):
"""Set up Appium driver for each test case"""
platform = os.getenv("TEST_PLATFORM", "android").lower()
app_filename = "app-rc-v.1.9.4-807d51a3.apk"

if not app_filename:
raise ValueError("TEST_APP_FILENAME not provided!")

if platform == "android":
caps = UiAutomator2Options()
caps.set_capability("platformName", "Android")
caps.set_capability("appium:platformVersion", "15")
caps.set_capability("appium:deviceName", "Google Pixel 9")
caps.set_capability("appium:automationName", "UiAutomator2")
caps.set_capability("appium:app", f"storage:filename={app_filename}")
caps.set_capability("autoGrantPermissions", True)
caps.set_capability("hideKeyboard", True)
caps.set_capability("autoHideKeyboard", True)

else:
raise ValueError(f"Unsupported platform: {platform}")

# Sauce Labs options
sauce_options = {
"username": os.getenv("SAUCE_USERNAME", "USERNAME"),
"accessKey": os.getenv("SAUCE_ACCESS_KEY", "SAUCE_ACCESS_KEY"),
"build": f"appium-build-{platform.upper()}",
"name": self.__class__.__name__,
"deviceOrientation": "PORTRAIT",
"appiumVersion": "2.0.0"
}
caps.set_capability("sauce:options", sauce_options)

self.driver = webdriver.Remote(self.SAUCE_URL, options=caps)
self.wait = WebDriverWait(self.driver, 10)

def tearDown(self):
"""Close driver and update job status in Sauce Labs"""
if hasattr(self, "driver") and self.driver:
job_status = "passed" if sys.exc_info()[0] is None else "failed"
try:
self.driver.execute_script(f"sauce:job-result={job_status}")
except Exception as e:
print(f"Failed to update Sauce Labs job status: {e}")

try:
self.driver.quit()
except Exception as e:
print(f"Failed to quit the driver: {e}")

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post