1

I want to run a selenium script on mobile devices.

For this purpose, I am using the Browserstack website.

Now, the problem is, I have written a script and it runs properly in web browser.

But, when I run it for the mobile device it gives me an error.

I'm sharing with you my code and my browser stack video link and also the console error I am getting. Kindly look at it once and help me how we solve this issue?

Video link :

https://drive.google.com/file/d/1HxQdZb0r0tsiw160-m7UiSMS_BdVJBl6/view?usp=sharing

Code of my script :

     import time
        
        from selenium import webdriver
        from selenium.webdriver import ActionChains
        from selenium.webdriver.support.select import Select

            
      
    
      BROWSERSTACK_URL = 'https://muhammadyousufkh1:[email protected]/wd/hub'
        
        

desired_cap = {
    "os_version" : "7.0",
    "device" : "Samsung Galaxy S8",

"real_mobile" : "true",
"browserstack.local" : "false"
    }

    driver = webdriver.Remote(
        command_executor=BROWSERSTACK_URL,
        desired_capabilities=desired_cap
    )
    
    driver.get("https://catevolution.com.au/litter-robot-3-connect.html")
    time.sleep(3)
    action = ActionChains(driver)
    action.move_to_element(driver.find_element_by_xpath("//header//strong[contains(text(),'Litter Robot')]")).perform()

    action.move_to_element(driver.find_element_by_link_text("Litter-Robot Connect")).click().perform()
    
    dropdown = Select(driver.find_element_by_id("input-option240"))
    dropdown.select_by_visible_text("Grey (SKU: LR3C-1200 )")
    
    print("***********************Scrolled down starts***************")
    for i in range(10):
        time.sleep(0.5)
        driver.execute_script("window.scrollBy(0,350);")
        print("scrolling time: " + str(i))

    print("*************************scrolling down end**********************")
    
    time.sleep(3)
    print("**************************************Scrolled up starts****************")
    
    for i in range(10):
        time.sleep(0.5)
        driver.execute_script("window.scrollBy(0,-350);")
        print("scrolling time: - " + str(i))
    
    print("**************************************Scrolled up End ****************")

Error showing in the mobile device when running script;

File "C:\Users\tech-pc-11\PycharmProject\catt.py", line 26, in <module>
    action.move_to_element(driver.find_element_by_link_text("Litter-Robot Connect")).click().perform()
  File "C:\Users\tech-pc-11\PycharmProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 428, in find_element_by_link_text
    return self.find_element(by=By.LINK_TEXT, value=link_text)
  File "C:\Users\tech-pc-11\PycharmProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "C:\Users\tech-pc-11\PycharmProject\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\tech-pc-11\PycharmProject\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"Litter-Robot Connect"}
2
  • kindly tell me what is procedure helps me to run the same script on both desktop and mobile. Jan 21, 2021 at 13:43
  • If you are able to run the example from BrowserStack then I would double check the selectors using Remote Debugging if you can get your hands on an Android device.
    – kirbycope
    Jan 28, 2021 at 6:03

1 Answer 1

-1

Appium is primarily based totally at the WebDriver JSON Wire Protocol and consequently works extraordinarily properly additionally for cell internet checking out. Being a subset of the Selenium, it additionally gives infrastructure, platform, and language-agnostic interfaces that can be well suited with all principal internet browsers – additionally on Android and iOS. In this blog, Ill stroll you thru a simple instance of a way to use Appium / Selenium for cell go browser checking out the usage of actual Android and iOS gadgets and actual internet browsers on those systems. Kobiton is a cloud platform for executing computerized and guide cell and internet exams. Kobiton helps going for walks computerized exams with Selenium WebDriver (for internet applications) and Appium (for local and cell internet applications). You can check your websites together along with your favored language - no want to analyze unique scripting languages or analyze a brand new programming language. In addition, you furthermore may dont need to set up checking out SDKs or even the Appium binding may be an ache factor for check and dev team. When you run Appium withinside the cloud, there may be no want to put in Appium and install your gadgets. You'll have got right of entry to check on masses of browsers instantly. Today, I`ll stroll you thru a simple instance of a way to use Appium / Selenium for cell go-browser checking out the usage of actual Android and iOS gadgets and actual internet browsers on those systems on Kobiton

For More Information just visit the site: https://shapshare.com/read-blog/48587

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.