Enable Developer Tools on the iPhone : Open Safari on your iPhone: Go to Settings > Safari and scroll down to Advanced. Enable "Show Develop Menu": Make sure the "Show Develop Menu" option is toggled on.
Connect your iPhone to your MacBook : Physical Connection: Use a USB cable to connect your iPhone to your MacBook. Trust the Connection: You may need to trust the device on both the iPhone and the Mac to establish the connection.
Open Safari on your MacBook : Go to Safari > Preferences > Advanced: Make sure "Show Develop menu in menu bar" is checked. Open the Develop Menu: Click on "Develop" in the Safari menu bar on your MacBook. Choose your iPhone: The Develop menu should list your connected iPhone (or iPad). Click on your device's name. Inspect the URL: The Develop menu should now list any open URL in the Safari browser on your iPhone. Click on that URL to open the Web Inspector.
Use the Web Inspector: Access the JavaScript Console: You'll find the JavaScript console within the Web Inspector. Debug and Inspect: Use the console to execute JavaScript, set breakpoints, view logs, and inspect the elements on your iPhone's Safari page.
Running Automated Tests : Use Test Automation Tools : You can integrate the Web Inspector with test automation tools to run tests and inspect the console output. Access Console Logs: You can capture and analyze the JavaScript console logs generated during your automated tests.