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 it runs in browser invocation right .but when I run in the mobile device it gives me an error. I will share with you my code and my browser stack video link and also show you my console error. kindly look at it once and tell me how we solve this query.
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 show in the mobile device when a 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"}