-1

Hi everyone I need help the problem is I have a selenium python automation script and I work fine on desktop but now I want to test in browser stack in mobile anyone have any idea how we test in it

   driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
    driver.get("https://catevolution.com.au/litter-robot-3-connect.html")
    driver.maximize_window()
   
 time.sleep(3)
    action = ActionChains(driver)
    action.move_to_element(driver.find_element_by_xpath(
        "//header/div[2]/div[1]/div[2]/div[2]/div[2]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/ul[1]/li[1]/a[1]/span[1]/strong[1]")).perform()
    time.sleep(3)

action.move_to_element(driver.find_element_by_link_text("Litter-Robot Connect")).click().perform()
    time.sleep(3)
    driver.execute_script("window.scrollTo(0, 350);")
    driver.switch_to.frame("zip-widget zip-widget__iframe zip-widget__iframe--type-productwidget")
    dropdown = Select(driver.find_element_by_id("input-option240"))


 dropdown.select_by_visible_text("Grey (SKU: LR3C-1200 ) ")
    driver.switch_to.default_content()
    time.sleep(5)
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    driver.quit()
  • Have a look on StackOverflow for similar questions https://stackoverflow.com/questions/61681097/python-and-selenium-mobile-emulation – William Baker Morrison Jan 15 '21 at 14:38
  • 1
    Does this answer your question? [Python and Selenium mobile emulation](https://stackoverflow.com/questions/61681097/python-and-selenium-mobile-emulation) – stuckoverflow Jan 15 '21 at 14:46

1 Answers1

0

This should help: https://www.browserstack.com/docs/automate/selenium/migrate-existing-test-suites#python

There's a sample code as well. You'll just need to set the capabilities for the device you want to run your test.

Capability page: https://www.browserstack.com/automate/capabilities

As a side note, remove driver.maximize_window(). You cannot maximize the windows on a mobile device. This will throw an exception.

Shawn Lobo
  • 204
  • 1
  • 3