TestProject Forum

Testing on Mobile view/layout

I’m trying to implement web testing on a site with mobile page layout and I’m unable to test the mobile version. I want to test it by Inspecting Chrome and using the mobile emulator (without BrowserStack, or Android emulator or plugging in the phone).
What I have tried so far:

  1. Navigate to the url on the desktop, manually change the view to mobile using devtools and then later start recording the test.
    Result: I am able to record it, but once I save the test and run it – it defaults to the desktop view and fails since it cant find the elements recorded on mobile view.
  2. Started recording the test from the beginning > Send keys F12 to open devtools to change view and record.
    Result: Step “Send F12” passes with message: Key sent. But in reality it does not open devtools.

    I am unable to proceed with my tests at this point because TestProject is unable to set the mobile view. I want to avoid using AndroidStudio emulators or plugging in actual devices for tests, since these tests will be run by many across teams and want to keep it straightforward. I would greatly appreciate it if you could reach out to me and help solve this issue.
    Thank you!

Note: The solution on Recording Mobile Page Layout did not help much.

Hello @tpatil
In the recorder, you will be able to do so, but while executing your tests you can’t make chrome change its view style to a web view.
May I ask why not use an emulator or a real device to run those web tests on your mobile browesr?

Thank you for your reply Ran.
I wanted to use a real device, but then everytime I need to run the test, the device needs to be connected. Is that right?
Another concern is for example: I connect my Samsung Android device and record the tests. But if another team member wants to run those tests, and owns a Pixel android phone will they be able to run my tests.

Hello @tpatil
Once you record the test on a device/emulator it can run on any other device.
You just need to make sure that element locators in your tests are not absolute, e.g they are using static locator strategies like text or id, and not hirerchly locators that can break on different device resolutions.

That makes sense. I will try that out and should work.
Thank you!