title,body,link,tags,view_count,is_answered,score,answer_count
XCUI Distributed UI Testing,"<p>I am working on XCUI test automation for an application involving two devices- for instance a video call application.</p>
<p>Currently I have two projects- project A running device 1's automation and project B running device 2's automation.</p>
<p>Is there a way in XCUI to achieve this with a single project?</p>
",https://stackoverflow.com/questions/73733091/xcui-distributed-ui-testing,"['xcode', 'xctest', 'xcuitest']",44,False,1,1
Compose Test rule Ui Testing,"<p>I am trying to test the compose layout using composeTestRule, I am trying to write a custom matcher to get the following sibling node. Is there any way we can write our own custom matcher to select the next/following sibling node?</p>
<p>Tried to use the getSiblings matcher but its returning all the siblings. But I just wanted the following/ next sibling.</p>
",https://stackoverflow.com/questions/74398613/compose-test-rule-ui-testing,"['android', 'android-jetpack-compose', 'ui-automation', 'android-espresso', 'android-jetpack-compose-testing']",357,False,1,0
AWS Lambda selenum UI testing,"<p>So I have written a bunch of selenium UI tests for a web app that is hosted privately on GitHub and I want to run these tests from AWS Lambdas. My question is how do I get the testing file to be able to interact with the rest of the GitHub repo, as there are models and libraries that the Selenium testing relies on the main GitHub repo.</p>
<p>I was thinking of just zipping the repo and uploading it to Lambdas and then running the testing on it but that doesn't strike me as the best way to do it.</p>
<p>Any help is appreciated,</p>
<p>Thanks</p>
",https://stackoverflow.com/questions/72855834/aws-lambda-selenum-ui-testing,"['amazon-web-services', 'selenium', 'testing', 'aws-lambda']",26,False,0,0
Swift Mocking Unit/ UI Testing,"<p>Basically I have a fairly large project built in MVP for which I need to incorporate UI and Unit testing wherever applicable.
The project has a large number of API calls, the client has requested that API calls be <strong>mocked</strong> within the App (Dummy data). So basically I need two targets in the App, one most likely the Production and the other just for testing where it does not contact the server and just mocks the requests and sends static pre defined Json data to the response handlers for the app to function with. The solution that I initially thought of was creating a global bool value and depending on the project target selected (Production (Bool value = False),Testing (Bool value = True)) so wherever a request is being made in the code, it would check this bool value and then choose to go with either the Testing Dummy Request (which returns static pre defined Json DATA to the response handler) or Live API request. But this kinda makes the code messy.
I'm fairly new to Unit/UI testing so Id appreciate any suggestions.
Thanks in advance :).</p>
",https://stackoverflow.com/questions/73111575/swift-mocking-unit-ui-testing,"['swift', 'xcode', 'unit-testing', 'mocking', 'xcode-ui-testing']",174,False,0,0
UI Testing - Jetpack Compose - Hilt,"<p><em>Edit</em> I still need help with this ActivityNotFound error. Am I missing something from my manifest file? How would I do that? Do I need to declare my HiltTestRunner somewhere? I am so lost at this point lol. Please help.</p>
<p>I am trying to learn how to test with Jetpack Compose and I'm feeling lost. I'm not sure what I am doing wrong. I want to test the MainScreen, but it is nested in a ScreenNavigation() and needs a ViewModel and a NavController. I'm really confused how this works. It is telling me it can't find the activity. Im not sure what to do in the AndroidManifest file. Any help is very much appreciated!</p>
<p>Error: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.samm.brewerysearch.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared ?</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest 
xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&gt;
&lt;uses-permission android:name=&quot;android.permission.CALL_PHONE&quot;/&gt;


&lt;application
    android:name=&quot;com.samm.brewerysearch.BrewApplication&quot;
    android:allowBackup=&quot;true&quot;
    android:dataExtractionRules=&quot;@xml/data_extraction_rules&quot;
    android:fullBackupContent=&quot;@xml/backup_rules&quot;
    android:icon=&quot;@mipmap/ic_launcher&quot;
    android:label=&quot;@string/app_name&quot;
    android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
    android:supportsRtl=&quot;true&quot;
    android:theme=&quot;@style/Theme.Bloomberg&quot;
    tools:targetApi=&quot;31&quot;&gt;
    &lt;activity
        android:name=&quot;com.samm.brewerysearch.MainActivity&quot;
        android:exported=&quot;true&quot;
        android:theme=&quot;@style/Theme.Bloomberg&quot;&gt;
        &lt;intent-filter&gt;
            &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;

            &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
        &lt;/intent-filter&gt;
    &lt;/activity&gt;

&lt;/application&gt;
</code></pre>

<pre><code>@HiltAndroidTest
@UninstallModules(AppModule::class)
class MainScreenTest {

    @get:Rule(order = 0)
    val hiltRule = HiltAndroidRule(this)

    @get:Rule(order = 1)
    val composeRule = createAndroidComposeRule&lt;MainActivity&gt;()

    @Before
    fun setUp() {
        hiltRule.inject()

        composeRule.setContent {
            val navController = rememberNavController()
            
            BreweryTheme {
                NavHost(
                    navController = navController,
                    startDestination = Screens.MainScreen.name
                ){
                    composable(Screens.MainScreen.name){
                        MainScreen(
                            navController = navController,
                            mainViewModel = hiltViewModel(),
                            search = Constants.DEFAULT_CITY
                        )
                    }
                }
            }
        }
    }


    @Test
    fun myTest(){
        composeRule.onNodeWithText(Constants.DEFAULT_CITY).assertIsDisplayed()
    }
}
</code></pre>
",https://stackoverflow.com/questions/73839854/ui-testing-jetpack-compose-hilt,"['android', 'kotlin', 'android-jetpack-compose']",609,True,0,2
Jetpack Compose UI Testing Button onClick,"<p>I'm trying to test how a buttonClick would change the UI.</p>
<p>The test is setup like this:</p>
<pre><code>composeRule.setContent {
    var i by remember { mutableStateOf(0) }
    Button(modifier = Modifier.testTag(&quot;TEST&quot;), onClick = { i++ }) {
        Text(text = i.toString())
    }
}
</code></pre>
<p>And my actual test looks like this:</p>
<pre><code>val button = composeRule.onNodeWithTag(&quot;TEST&quot;)

button.assertTextEquals(&quot;0&quot;)
button.performClick()
button.printToLog(&quot;Test&quot;)
button.assertTextEquals(&quot;1&quot;)
</code></pre>
<p>The first assertion passes, however it fails when checking that the text should equal <code>1</code>:</p>
<pre><code>java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [1])
Semantics of the node:
Node #2 at (l=0.0, t=66.0, r=176.0, b=165.0)px, Tag: 'TEST'
Role = 'Button'
Text = '[0]'
Actions = [OnClick, GetTextLayoutResult]
MergeDescendants = 'true'
Selector used: (TestTag = 'TEST')
</code></pre>
<p>The printToLog() after the click looks like this:</p>
<pre><code>Printing with useUnmergedTree = 'false'
Node #2 at (l=0.0, t=66.0, r=176.0, b=165.0)px, Tag: 'TEST'
Role = 'Button'
Text = '[0]'
Actions = [OnClick, GetTextLayoutResult]
MergeDescendants = 'true'
</code></pre>
<p>So it appears that when the click is performed, either the content is not recomposed, or for some reason, the click isn't actually happening.</p>
<p>Does anyone know what might be going on here?</p>
",https://stackoverflow.com/questions/71695189/jetpack-compose-ui-testing-button-onclick,"['android', 'kotlin', 'android-jetpack-compose', 'ui-testing']",3245,True,6,1
GitLab CI: UI Testing with Selenium,"<p>I have built some UI tests for my application using Selenium and PyTest. I want to automate these tests by integrating the in the GitLab CI. As the latter is docker-based and I am building by UI using a docker-compose script, I need docker in docker (<code>docker:dind</code>) capabilities besides Firefox, Selenium and Python.</p>
<p>My current <code>gitlab-ci.yml</code> looks like this:</p>
<pre><code>ui_test:
  stage: Build_and_Test
  image:
    name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker/compose
    entrypoint: [ '/bin/sh', '-c' ]
  services:
    - name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:dind
      alias: docker
    - selenium/standalone-firefox:latest
  variables:
    GET_SOURCES_ATTEMPTS: 1
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ''
    PROXY_REGISTRY_PREFIX: '${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/'
  before_script:
    - apk add --update --no-cache bash git openssh gcc musl-dev g++ make build-base libffi-dev python3-dev libressl-dev python3 wget tar npm
    - apk --no-cache add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community firefox
    - echo which firefox
    - python3 -m ensurepip
    - wget https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz
    - tar -xvf geckodriver-v0.31.0-linux64.tar.gz
    - chmod +x geckodriver
    - export PATH=$PATH:/builds/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
  script:
    - docker login -u &quot;$CI_DEPENDENCY_PROXY_USER&quot; -p &quot;$CI_DEPENDENCY_PROXY_PASSWORD&quot; &quot;$CI_DEPENDENCY_PROXY_SERVER&quot;
    - alias python=python3
    - echo 'alias python=python3' &gt;&gt; ~/.bashrc
    - source ~/.bashrc
    - python3 -m pip install --upgrade pip setuptools wheel
    - python3 -m pip install --no-cache-dir --upgrade cryptography requests webdriver-manager
    - python3 -m pip install --no-cache-dir --upgrade pytest
    - python3 -m pip install --no-cache-dir --upgrade pytest-asyncio
    - python3 -m pip install --no-cache-dir selenium==4.1.5
    - mkdir -p ./test_output
    - ./docker/build_hdssl_mock.sh
    - ./docker/start_hdssl_mock.sh &amp; cd ui &amp; npm run serve &amp; python3 -m pytest hdssl_control/tests/acceptance_tests
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_PIPELINE_SOURCE == &quot;merge_request_event&quot; || $CI_COMMIT_BRANCH == &quot;develop&quot;
</code></pre>
<p>The problem here is that Firefox requires all kinds of dependencies that I do not know how to install in Alpine:</p>
<pre><code>ERROR: unsatisfiable constraints:
  so:libcjson.so.1 (missing):
    required by: librist-0.2.6-r1[so:libcjson.so.1]
  so:libmbedcrypto.so.7 (missing):
    required by: librist-0.2.6-r1[so:libmbedcrypto.so.7]
  so:libffi.so.8 (missing):
    required by: firefox-101.0.1-r0[so:libffi.so.8]
  so:libicui18n.so.71 (missing):
    required by: firefox-101.0.1-r0[so:libicui18n.so.71]
  so:libicuuc.so.71 (missing):
    required by: firefox-101.0.1-r0[so:libicuuc.so.71]
</code></pre>
<p>Any help is greatly appreciated.</p>
",https://stackoverflow.com/questions/72575611/gitlab-ci-ui-testing-with-selenium,"['docker', 'selenium', 'user-interface', 'testing', 'firefox']",232,False,0,0
OneTimeTearDown not executing C# UI Testing,"<p>I am having trouble getting a teardown to execute that is supposed to delete all of the accounts my automation creates on our application. I elected to use a OneTimeTearDown so it executes once and just goes through the list but it doesn't seem to be executing. Here is the code, am I putting it in the wrong place maybe? The code in the teardown works as intended on its own if I just add it to the end of the test.</p>
<pre>

    namespace Ag.AutomatedRegression.UI.Tests.AccountsTests
    {
        [TestFixture]
        public class AccountsPageTests : BaseSetup
        {
            [OneTimeTearDown]
            public void CleanUpAccounts()
            {
    
                LogList.Add($""Entered the {MethodBase.GetCurrentMethod()}()."");
                for (int i = AccountsPageTests.accountIdList.Count - 1; i >= 0; i--)
                {
                    if (AccountsPageTests.accountIdList.Count == 0)
                    {
                        LogList.Add(""There were no ids in the list to delete."");
                        break;
                    }
                    else
                    {
                        LogList.Add(""Next Step: Clean Up accounts created this session."");
                        PerformBrowserManagerAction.NavigateToURL(CommonSettings.Default.URL);
                        PerformCommonStagesAction.CleanUpAccounts(CommonSettings.Default.UserName,
                                                                  CommonSettings.Default.EncryptedPassword,
                                                                  AccountsPageTests.accountIdList[i]);
                    }
    
                    LogList.Add(""Account Cleanup was successful."");
                }
            }
            public static List accountIdList = new List();
            
    
    
            [Test]
            public void CreateAccountTest()
            {
                LogList.Add($""Entered the {MethodBase.GetCurrentMethod()}()."");
    
                //Code to create account with account id string variable
               
                Assert.That(Success, Is.True, expectedMessage + ""\r\n"" + 
        actualMessage);    
            }
        }
    }

</pre>
",https://stackoverflow.com/questions/72632912/onetimeteardown-not-executing-c-ui-testing,"['c#', 'selenium-webdriver', 'nunit', 'ui-automation']",46,False,0,3
Compose UI testing - How do I assert a text color?,"<p>I'm trying to test a <code>Text</code> that on my component I can print it in different colors, so on my test I'm verifying it gets the expected color. I was looking for a method to return the color but I did not find any.</p>
<p>From now I'm asserting that the text is correct and the visibility is correct, but when trying to find the method to get the colour I get too deep and I'm looking for a simpler solution.</p>
<pre><code>composeTestRule.onNode(hasTestTag(&quot;testTagForButton&quot;), true)
            .assertExists()
            .assertTextEquals(&quot;Testing&quot;)
</code></pre>
<p>I've check that I can do something like <code>.fetchSemanticsNode().layoutInfo.getModifierInfo()</code> to get into the <code>Modifier</code> and perhaps from there I can get the colour, but it's too much maybe. Also I've found this <code>.captureToImage()</code> that perhaps I could get the colour on it, but since I had to put the pixels I decided that it's not the way.</p>
<p>Is there any simple way to get that?</p>
",https://stackoverflow.com/questions/70988755/compose-ui-testing-how-do-i-assert-a-text-color,"['android', 'kotlin', 'android-jetpack-compose', 'android-jetpack', 'android-jetpack-compose-testing']",2651,True,16,2
if else case in Android Espresso UI testing,"<p>In the application, I am writing Espresso UI test for login flow in the app. I wrote the test and it works fine, but I have one case where I have problem.</p>
<p>In this application, users sometimes get bonuses when opening app (usually they don't but this is let's say 1:100 scenario)
In these situations, the pop up appears on the screen and my test fails because my code tries to trigger the button that is not visible (it is under the pop up).</p>
<p>I would like to write if-else in a test where I can for example check the visibility of the pop up close button. So if this is visible click on it and if it's not, then continue normally.</p>
<p>But I didn't find any if-else syntax in UI testing. Can someone with more experience in UI espresso testing help me with some advice here? THanks</p>
",https://stackoverflow.com/questions/71666138/if-else-case-in-android-espresso-ui-testing,"['android', 'kotlin', 'android-espresso', 'ui-testing']",525,True,1,2
Android Wear and Android app parallel ui testing,"<p>I have both Android App which act as receiver for heart rate from Android Watch and app for Wear OS, which sent heart rate to the app.<br />
For test without my hardware, i created two emulators and paired them. Manual testing show that apps working just fine, watch sends heart rate data and app received it</p>
<p>But I have next questions:</p>
<ol>
<li><p>When app reaches a specific test package inside the phone test code - is there a way to automatically run an emulator of Wear OS device, install a specific apk, and start tests package (which would be synchronized with a test flow in app to pass) ?</p>
</li>
<li><p>There is no solution for such level of automation yet, and I should stick to mocking info for both devices - mock received heart rate from wearOS in the phone, and mock received info from the phone on the wearOS device ?</p>
</li>
<li><p>Or there are other solutions for this case ?</p>
</li>
</ol>
",https://stackoverflow.com/questions/74191761/android-wear-and-android-app-parallel-ui-testing,"['android', 'wear-os', 'android-testing', 'parallel-testing']",70,True,1,1
Automated UI testing w/ Selenium - Thread.Sleep vs Task.Delay,"<p>I have some automated tests written with Selenium.
Is there any practical difference between using Thread.Sleep vs await Task.Delay?
Both seem to achieve the same thing (cause selenium to wait before continuing execution).</p>
<p>Note that my current understanding is that Thread.Sleep does NOT pause the UI thread, but rather it pauses the Selenium thread. Not sure if this is true however. But if it is true, then i'd imagine there is not practical difference between Thread.Sleep &amp; await Task.Delay.</p>
",https://stackoverflow.com/questions/74187758/automated-ui-testing-w-selenium-thread-sleep-vs-task-delay,"['multithreading', 'selenium', 'task']",21,False,0,0
How to deal with google maps during UI testing,"<p>Our company uses <a href=""https://softwareengineering.stackexchange.com/questions/358786/what-is-golden-files"">golden files</a> for our automated UI testing. It detects UI changes caused by code changes during our PR pipeline Continous Integration. However, it detects several false changes which were caused by the Map not loading properly due to internet latency.</p>
<p>For the case below, notice the white areas on the left. The testing software thought these were UI changes which are actually not and the test for this case failed even though it was supposed to pass.</p>
<p>Does anyone have any experience dealing with Google maps on any framework like Javascript, Android, or iOS when doing UI Testing?</p>
<p>Ideally, it would be best if a tiny portion of the Google map is downloaded offline during the UI testing but does the Google Maps SDK has anything for that?</p>
<p>If not, can we replace the image layer of a specific region on the map with a static offline image or can we mock the API calls done by the map to load those tiles?</p>
<p><a href=""https://i.stack.imgur.com/TWkPW.jpg"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/TWkPW.jpg"" alt=""enter image description here"" /></a></p>
",https://stackoverflow.com/questions/73655094/how-to-deal-with-google-maps-during-ui-testing,"['android', 'google-maps', 'testing', 'google-maps-api-3', 'google-maps-sdk-ios']",195,False,1,0
Android Compose App Crashes during UI Testing (Instrumented Tests),"<p>I'm following Android Studio's Documentation for learning Kotlin and Jetpacks Compose. For Unit 2, Pathway 3, we are supposed to practice writing both local tests and instrumented tests for the Tip Calculator App that was developed.</p>
<p>When I manually tested the App, it works but it fails the Instrumented Test as the entire app closes during UI Testing. As a result, I encounter an Assertion Error,</p>
<pre><code>java.lang.AssertionError: Failed: assertExists.
Reason: Expected exactly '1' node but could not find any node that satisfies: (Text + EditableText contains 'Tip Amount: $2.00' (ignoreCase: false))

at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:162)
at androidx.compose.ui.test.SemanticsNodeInteraction.assertExists(SemanticsNodeInteraction.kt:137)
at androidx.compose.ui.test.SemanticsNodeInteraction.assertExists$default(SemanticsNodeInteraction.kt:136)
at com.example.tipcalculator.TipCalculatorInstrumentedTestUI.calculate_20_percent_tip(TipCalculatorInstrumentedTestUI.kt:46)
</code></pre>
<p>Does anyone know why this maybe happening? I have attached both my Tip Calculator App Code and Instrumented Tests codes below:</p>
<ol>
<li>Instrumented Tests</li>
</ol>
<pre><code>package com.example.tipcalculator

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performTextInput
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.tipcalculator.ui.theme.TipCalculatorTheme

import org.junit.Test
import org.junit.Rule
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class TipCalculatorInstrumentedTestUI {
    @get: Rule
    val composeTestRule = createComposeRule()

    // Compiler knows @Test in androidTest refers to Instrumented Tests, while in Test Directory refers to Local Tests
    @Test
    fun calculate_20_percent_tip() {
        // Set the UI Content, Code looks similar to Main Activity SetContent where we render the Screen and App
        composeTestRule.setContent {
            TipCalculatorTheme {
                TipCalculatorScreen()
            }
        }

        // Accessing the UI Component as a Node to access its particular text with onNodeWithText() method to access TextField Composable
        composeTestRule.onNodeWithText(&quot;Bill Amount&quot;)
            .performTextInput(&quot;10&quot;)     // Pass in the Value of the Text that we wants to populate it with

        // Apply Same Approach for Tip Percentage
        composeTestRule.onNodeWithText(&quot;Tip (%)&quot;)
            .performTextInput(&quot;20&quot;)

        // Use Assertion to ensure that the Text Composable reflects the accurate Tip to be given
        composeTestRule.onNodeWithText(&quot;Tip Amount: $2.00&quot;).assertExists()
    }
}
</code></pre>
<ol start=""2"">
<li>Application Code</li>
</ol>
<pre><code>package com.example.tipcalculator

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.tipcalculator.ui.theme.TipCalculatorTheme
import java.text.NumberFormat
import kotlin.math.round

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TipCalculatorTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    TipCalculatorScreen()
                }
            }
        }
    }
}

@Composable
fun TipCalculatorScreen() {
    // Mutable State that receives 0 as a parameter wrapped in a State Object, making its value observable
    var amountInput by remember {
        // Importing remember setter and getter functions allows us to read and set amountInput
        mutableStateOf(&quot;&quot;)
    }

    // Mutable State for Tip
    var tipInput by remember {
        mutableStateOf(&quot;&quot;)
    }

    // Variable to remember State of the Switch
    var roundUp by remember {
        mutableStateOf(false)
    }

    // Interface to Control Focus in Compose
    val focusManager = LocalFocusManager.current

    // Convert to Double or a Null. If Null, return 0 after the Elvis Operator
    val amount = amountInput.toDoubleOrNull() ?: 0.0
    val tipPercentage = tipInput.toDoubleOrNull() ?: 0.0
    
    // Calculate Tip
    val tip = CalculateTip(amount = amount, tipPercent = tipPercentage, roundUp = roundUp)

    Column(
        verticalArrangement = Arrangement.spacedBy(8.dp),
        modifier = Modifier
            .padding(32.dp)
    ) {
        // Screen Title
        Text(
            text = stringResource(id = R.string.calculate_tip),
            fontSize = 24.sp,
            modifier = Modifier
                .align(Alignment.CenterHorizontally)
        )

        Spacer(modifier = Modifier.height(16.dp))
        // Text Field for User
        // Pass the Hoisted State back into the Child Function
        EditNumberField(
            value = amountInput,
            onValueChange = { amountInput = it },
            label = R.string.bill_amount,
            keyboardOptions = KeyboardOptions(
                imeAction = ImeAction.Next,
                keyboardType = KeyboardType.Number
            ),
            keyboardActions = KeyboardActions(
                // Move Focus downwards to the next composable when the Next Button is clicked
                onNext = {
                    focusManager.moveFocus(FocusDirection.Down)
                }
            )
        )

        // Input Field for Tip Percentage
        EditNumberField(
            label = R.string.how_was_the_service,
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Number,
                imeAction = ImeAction.Done
            ),
            keyboardActions = KeyboardActions(
                // Closes the Keyboard when Done is pressed
                onDone = { focusManager.clearFocus() }
            ),
            value = tipInput,
            onValueChange = { tipInput = it }
        )

        // Rounding Function
        RoundTipRow(
            // Setting Initial State
            roundUp = roundUp,
            // Updating the State when the Switch is clicked
            onRoundUpChanged = { roundUp = it }
        )

        Spacer(modifier = Modifier.height(24.dp))

        // Display the Tip Amount to be given
        Text(
            // Can use tip to sub into placeholder as the String has a %s placeholder
            text = stringResource(id = R.string.tip_amount, tip),
            fontSize = 20.sp,
            fontWeight = FontWeight.Bold,
            modifier = Modifier
                .align(Alignment.CenterHorizontally)
        )
    }

}

@Composable
fun EditNumberField(
    // Hoist the State by introducing 2 Parameters
    @StringRes label: Int,      // To indicate that it is meant to be a String Resource
    keyboardOptions: KeyboardOptions,
    keyboardActions: KeyboardActions,
    value: String,
    onValueChange: (String) -&gt; Unit,     // Takes a string as input but has no output
    modifier: Modifier = Modifier
) {
    TextField(
        value = value,     // Set to Empty String; Since TextBox that displays the Value
        onValueChange = onValueChange, // Set to Empty Lambda Function; Callback that is triggered when User enters text
        label = { Text(text = stringResource(label))}, // Using Label instead of Hardcoding
        modifier = Modifier
            .fillMaxWidth(),
        singleLine = true,       // Ensures text box is a single horizontal textbox that is scrollable
        keyboardOptions = keyboardOptions, // Changing the look of the keyboard
        keyboardActions = keyboardActions   // Functionality for the Action Buttons i.e. Next/Done
    )
}

// Rounding Tip Switch Function
@Composable
private fun RoundTipRow(
    modifier: Modifier = Modifier,
    // Allowing us to hoist the state of the switch
    roundUp: Boolean,
    onRoundUpChanged: (Boolean) -&gt; Unit
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .size(48.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        // Text for Rounding Tip
        Text(text = stringResource(id = R.string.round_up_tip))
        
        Switch(
            // Determines whether the Switch is Checked, i.e. the Current State
            checked = roundUp,
            // Callback called when the Switch is clicked
            onCheckedChange = onRoundUpChanged,
            modifier = Modifier
                .fillMaxWidth()
                .wrapContentWidth(Alignment.End),
            colors = SwitchDefaults.colors(
                // Bad Practice since we are hardcoding the color and will be affected if Dark Mode is implemented for example
                uncheckedThumbColor = Color.DarkGray
            )
        )

    }
    
}

// Calculate Tip; Cannot be Private or the Local Tests will not have access to them
@VisibleForTesting      // Makes the Function Public but only for Testing purposes
internal fun CalculateTip(
    amount: Double,
    tipPercent: Double = 15.0,
    roundUp: Boolean
): String {
    var tip = tipPercent / 100 * amount

    if (roundUp == true) {
        // Rounding Up
        tip = kotlin.math.ceil(tip)
    }
    // After calculating the tip, format and display the tip with the Number Class
    return NumberFormat.getCurrencyInstance().format(tip)
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    TipCalculatorTheme {
        TipCalculatorScreen()
    }
}
</code></pre>
<p>Thank you</p>
",https://stackoverflow.com/questions/74725792/android-compose-app-crashes-during-ui-testing-instrumented-tests,"['android', 'unit-testing', 'kotlin', 'android-jetpack-compose']",619,False,0,1
How can you perform UI Testing without Using Mocks?,"<p>I have SwiftUI application and I need to test my user interface. The interface contains login view, where the button sends a request to the authentication service and get result back. Since, I am not using Mocks how can I test my interface. For the UI Test, I can switch to the test server but then I am very close to writing an end to end test.</p>
<p>Would it make sense to skip UI Tests and simply perform End to End testing with a real test server?</p>
",https://stackoverflow.com/questions/74704413/how-can-you-perform-ui-testing-without-using-mocks,"['ios', 'testing']",16,False,0,0
Not able to use MockK in Android Espresso UI Testing,"<p>I am getting a error when trying to use MockK in UI test which was perfectly working in Unittest cases</p>
<pre><code>MockK could not self-attach a jvmti agent to the current VM
</code></pre>
<p><strong>Full error report</strong></p>
<pre><code>Caused by: io.mockk.proxy.MockKAgentException: MockK could not self-attach a jvmti agent to the current VM. This feature is required for inline mocking.
This error occured due to an I/O error during the creation of this agent: java.io.IOException: Unable to dlopen libmockkjvmtiagent.so: dlopen failed: library &quot;libmockkjvmtiagent.so&quot; not found

Potentially, the current VM does not support the jvmti API correctly
at io.mockk.proxy.android.AndroidMockKAgentFactory.init(AndroidMockKAgentFactory.kt:67)
at io.mockk.impl.JvmMockKGateway.&lt;init&gt;(JvmMockKGateway.kt:46)
at io.mockk.impl.JvmMockKGateway.&lt;clinit&gt;(JvmMockKGateway.kt:186)
... 30 more
Caused by: java.io.IOException: Unable to dlopen libmockkjvmtiagent.so: dlopen failed: library &quot;libmockkjvmtiagent.so&quot; not found
at dalvik.system.VMDebug.nativeAttachAgent(Native Method)
at dalvik.system.VMDebug.attachAgent(VMDebug.java:693)
at android.os.Debug.attachJvmtiAgent(Debug.java:2617)
at io.mockk.proxy.android.JvmtiAgent.&lt;init&gt;(JvmtiAgent.kt:48)
at io.mockk.proxy.android.AndroidMockKAgentFactory.init(AndroidMockKAgentFactory.kt:40)
</code></pre>
<p>Let me know is there any other way to initialize the MockK to make use in Espresso</p>
<p>When tried to add</p>
<pre><code>androidTestImplementation &quot;org.mockito:mockito-inline:$mockitoVersion&quot;
</code></pre>
<p>Observed this error</p>
<p>2 files found with path 'mockito-extensions/org.mockito.plugins.MockMaker'.
Adding a packagingOptions block may help, please refer to
<a href=""https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ResourcesPackagingOptions"" rel=""nofollow noreferrer"">https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ResourcesPackagingOptions</a>
for more information</p>
<p><strong>Versions</strong></p>
<pre><code>mockk version = 1.12.4
Android = 32
kotlin_version = '1.6.21'
</code></pre>
<p><strong>Code which causes this issue when added in android UI testcases(Espresso)</strong></p>
<pre><code>val presenter = mockk&lt;LoginPresenter&gt;()

val view = mockk&lt;LoginView&gt;()
</code></pre>
<p><strong>How to perform a mock api call like this</strong></p>
<pre><code>val presenter = mockk&lt;LoginPresenter&gt;()
    val view = mockk&lt;LoginView&gt;()


onView(withId(R.id.button_login)).perform(loginClick())
</code></pre>
<p>But i want mock api to be called
instead of loginClick() in <strong>perform()</strong> can i call some how the below execution
so that my app uses mock api's
or is there any way to make my entire testcase file use mockk data</p>
<pre><code>every { presenter.onLoginButtonClicked(&quot;bc@mail.com&quot;,&quot;Abc123&quot;)  } returns  view.onCognitoLoginSuccess()
</code></pre>
",https://stackoverflow.com/questions/73146494/not-able-to-use-mockk-in-android-espresso-ui-testing,"['kotlin', 'mocking', 'android-espresso', 'coded-ui-tests', 'mockk']",1766,True,3,2
Abstract Method Error while UI testing in Compose with MockK,"<p>I'm trying to test WorkoutScreen with the following code block.
I created a function called setView to test ViewState in different situations.</p>
<pre><code>@HiltAndroidTest
@RunWith(AndroidJUnit4::class)
class WorkoutScreenTest {

    @get:Rule(order = 0)
    val hiltRule = HiltAndroidRule(this)

    @get:Rule(order = 1)
    val composeTestRule = createComposeRule()

    private val workoutViewModel = mockk&lt;WorkoutViewModel&gt;()

    private val playerManager = mockk&lt;ExoplayerManager&gt;()

    @Before
    fun setup() = runOnUiThread {
        hiltRule.inject()
        MockKAnnotations.init(this, true)
    }

    @OptIn(ExperimentalCoroutinesApi::class)
    @Test
    fun isCircularProgressDisplayed_whenLoading() = runTest {
        setView(isLoading = true, viewState = WorkoutViewState.Loading)
        composeTestRule.onNodeWithTag(&quot;workout_loading_indicator&quot;).assertIsDisplayed()
    }

    @OptIn(ExperimentalCoroutinesApi::class)
    @Test
    fun isErrorTextDisplayed_whenError() = runTest {
        setView(isLoading = true, viewState = WorkoutViewState.Error(&quot;error message&quot;))
        composeTestRule.onNodeWithText(&quot;Something went wrong&quot;).assertIsDisplayed()
    }

    private fun setView(isLoading: Boolean, viewState: WorkoutViewState) {
        runOnUiThread {
            val loading = MutableStateFlow(isLoading)
            val state = MutableStateFlow(viewState)
            val navController = TestNavHostController(ApplicationProvider.getApplicationContext())
            coEvery { playerManager.isLoading } answers { loading }
            coEvery { workoutViewModel.state } answers { state }
            coEvery { workoutViewModel.loadExercise(20001) } answers { }
            composeTestRule.setContent {
                AppTheme {
                    WorkoutScreen(viewModel = workoutViewModel, navController = navController)
                }
            }
        }
    }
}
</code></pre>
<p>This code was actually working. But after a while I started getting this error.
<code>java.lang.AbstractMethodError: abstract method &quot;boolean kotlin.reflect.KClass.isValue()&quot;</code></p>
<p>What am I doing wrong or what am I missing?</p>
",https://stackoverflow.com/questions/74825326/abstract-method-error-while-ui-testing-in-compose-with-mockk,"['kotlin', 'android-jetpack-compose', 'kotlin-coroutines', 'mockk']",198,False,1,0
Can&#39;t add accessibility identifier for HereMapSDK elements in UI Testing,"<p>I am writing UITest cases for HereMapSDK elements (NMAMapCircle, NMAMapPolyline, NMAMapMarker), but I can't add <code>accessibility identifier</code> for it.</p>
<p>As I can see in SDK, there isn't any property for adding <code>accessibility identifier</code>.</p>
<p>Can anyone suggest, how can I achieve this?</p>
<p>Thanks in advance!</p>
",https://stackoverflow.com/questions/71306591/cant-add-accessibility-identifier-for-heremapsdk-elements-in-ui-testing,"['ios', 'swift', 'here-api', 'heremaps', 'heremaps-ios-sdk']",69,False,0,1
Jetpack Compose Ui testing - TextField - Random Key events - Regression testing,"<p>I uploaded my app in the google play console for review and i got some crashes pre launch report. And on doing some research , i found that its bug inside jetpack compose TeXtFiled and its created my Google monkey test regressions. I referred the Official Android Developer docs and its been recommended to do ui test automation. I want to know how automate regression test on a textfield performing some random key events . I believe its causing when pressing Del, Backspace or Ctrl+ Backspace on a texttfield . Here is the Stack Trace :</p>
<pre><code>Fatal Exception: java.lang.IllegalArgumentException: end cannot negative. [end: -1]
at androidx.compose.ui.text.TextRangeKt.packWithCheck(TextRangeKt.java:1)
at androidx.compose.ui.text.input.EditingBuffer.delete$ui_text_release(EditingBuffer.java)
at androidx.compose.ui.text.input.DeleteSurroundingTextCommand.applyTo(DeleteSurroundingTextCommand.java:2)
at androidx.compose.ui.text.input.EditProcessor.apply(EditProcessor.java:2)
at androidx.compose.foundation.text.TextFieldKeyInput.apply(TextFieldKeyInput.java:2)
at androidx.compose.foundation.text.TextFieldKeyInput.access$apply(TextFieldKeyInput.java:59)
at androidx.compose.foundation.text.TextFieldKeyInput$process$2.invoke(TextFieldKeyInput.java:59)
at androidx.compose.foundation.text.TextFieldKeyInput$process$2.invoke(TextFieldKeyInput.java:59)
at androidx.compose.foundation.text.TextFieldKeyInput.commandExecutionContext(TextFieldKeyInput.java:14)
at androidx.compose.foundation.text.TextFieldKeyInputKt$textFieldKeyInput$2$1.invoke-ZmokQxo(TextFieldKeyInputKt.java:14)
at androidx.compose.foundation.text.TextFieldKeyInputKt$textFieldKeyInput$2$1.invoke(TextFieldKeyInputKt.java:14)
at androidx.compose.ui.node.ModifiedKeyInputNode.propagateKeyEvent-ZmokQxo(ModifiedKeyInputNode.java:5)
at androidx.compose.ui.input.key.KeyInputModifier.processKeyInput-ZmokQxo(KeyInputModifier.java:9)
at androidx.compose.ui.platform.AndroidComposeView.sendKeyEvent-ZmokQxo(AndroidComposeView.java:9)
at androidx.compose.ui.platform.AndroidComposeView.dispatchKeyEvent(AndroidComposeView.java:9)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1840)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1840)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1840)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1840)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:444)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1819)
at androidx.core.view.KeyEventDispatcher.activitySuperDispatchKeyEventPre28(KeyEventDispatcher.java:3)
at androidx.core.app.ComponentActivity.dispatchKeyEvent(ComponentActivity.java:18)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:358)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4979)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4851)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4385)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4438)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4404)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4531)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4412)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4588)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4385)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4438)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4404)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4412)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4385)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4438)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4404)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4564)
at android.view.ViewRootImpl$ImeInputStage.onFinishedInputEvent(ViewRootImpl.java:4733)
at android.view.inputmethod.InputMethodManager$PendingEvent.run(InputMethodManager.java:2430)
at android.view.inputmethod.InputMethodManager.invokeFinishedInputEventCallback(InputMethodManager.java:1993)
at android.view.inputmethod.InputMethodManager.finishedInputEvent(InputMethodManager.java:1984)
at android.view.inputmethod.InputMethodManager$ImeInputEventSender.onInputEventFinished(InputMethodManager.java:2407)
at android.view.InputEventSender.dispatchInputEventFinished(InputEventSender.java:141)
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:331)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:6662)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
</code></pre>
<p>How to write Ui test for this and fix this issue?</p>
",https://stackoverflow.com/questions/73523333/jetpack-compose-ui-testing-textfield-random-key-events-regression-testing,"['android-jetpack-compose', 'jetpack', 'android-jetpack-compose-text']",192,False,0,0
UI testing using Cypress with authentication to Azure AD using ADFS,"<p>These are my notes for how to UI test an Azure AD single page app using MSAL.js and ADFS (in our case on-premise) and the schema associated with the process of token creation and local storage.</p>
<p>From the tutorial: &quot;It uses the ROPC authentication flow to acquire tokens for a test user account, and injects them into browser local storage before running the tests. This way MSAL.js does not attempt to acquire tokens as it already has them in cache.&quot;</p>
<p>After watching the awesome video here:
<a href=""https://www.youtube.com/watch?v=OZh5RmCztrU"" rel=""noreferrer"">https://www.youtube.com/watch?v=OZh5RmCztrU</a></p>
<p>...and going through the repo here:
<a href=""https://github.com/juunas11/AzureAdUiTestAutomation"" rel=""noreferrer"">https://github.com/juunas11/AzureAdUiTestAutomation</a></p>
<p>I was stuck trying to match my use of on-premise ADFS with MSAL.js 2.0 and session store, with that of the above tutorial and code.  So if you are using the link to Azure ending with <strong>/adfs/oauth2/token</strong>  ( as opposed to oAuth /oauth2/v2.0/token ) - then follow the below!!</p>
<p>MOST of the changes I made were from auth.js: <a href=""https://github.com/juunas11/AzureAdUiTestAutomation/blob/main/UiTestAutomation.Cypress/cypress/support/auth.js"" rel=""noreferrer"">https://github.com/juunas11/AzureAdUiTestAutomation/blob/main/UiTestAutomation.Cypress/cypress/support/auth.js</a></p>
<p><strong>Simply follow the tutorial and copy in that content, then change the following:</strong></p>
<ul>
<li>const environment = ''; (mine was corporate domain NOT login.windows.net)</li>
<li>for the Account entity (const buildAccountEntity) use:<br />
<strong>authorityType: 'ADFS',</strong>
...and REMOVE the line: <strong>clientInfo: &quot;&quot;,</strong></li>
<li>for the Access Token entity: (const buildAccessTokenEntity):
...ADD the line:    <strong>tokenType: 'bearer',</strong></li>
<li>ADD a new function for the Refresh Token (new) entity:</li>
</ul>
<pre><code>    const buildRefreshTokenEntity = (homeAccountId: string, accessToken: string) =&gt; {
        return {
            clientId,
            credentialType: 'RefreshToken',
            environment,
            homeAccountId,
            secret: accessToken,
        };
    };
</code></pre>
<ul>
<li>next I had to MATCH my sessionStorage TOKEN by running it locally using VS Code and logging in then reverse-engineering the required KEY-VALUE pairs for what was stored (results are in next code block!).</li>
<li>Specifically I kept case-sensitivity for 'home account', I blanked-out some values, and had to add in the RefreshToken part, and mine used Session Storage (not local storage), and match the extended expires with the same value (based on my sample run through only):</li>
</ul>
<pre><code>const injectTokens = (tokenResponse: any) =&gt; {
    const scopes = ['profile', 'openid'];
    const idToken: JwtPayload = decode(tokenResponse.id_token) as JwtPayload;
    const localAccountId = idToken.sub; // in /oauth2/v2.0/token this would be: idToken.oid || idToken.sid;  however we are using /adfs/oauth2/token
    const realm = ''; // in /oauth2/v2.0/token this would be: idToken.tid;  however we are using /adfs/oauth2/token
    const homeAccountId = `${localAccountId}`; // .${realm}`;
    const homeAccountIdLowerCase = `${localAccountId}`.toLowerCase(); // .${realm}`;
    const usernameFromToken = idToken.upn; // in /oauth2/v2.0/token this would be: idToken.preferred_username;  however we are using /adfs/oauth2/token
    const name = ''; // in /oauth2/v2.0/token this would be: idToken.name;  however we are using /adfs/oauth2/token
    const idTokenClaims = JSON.stringify(idToken);

    const accountKey = `${homeAccountIdLowerCase}-${environment}-${realm}`;
    const accountEntity = buildAccountEntity(homeAccountId, realm, localAccountId, idTokenClaims, usernameFromToken, name);

    const idTokenKey = `${homeAccountIdLowerCase}-${environment}-idtoken-${clientId}-${realm}-`;
    const idTokenEntity = buildIdTokenEntity(homeAccountId, tokenResponse.id_token, realm);

    const accessTokenKey = `${homeAccountIdLowerCase}-${environment}-accesstoken-${clientId}-${realm}-${scopes.join(' ')}`;
    const accessTokenEntity = buildAccessTokenEntity(
        homeAccountId,
        tokenResponse.access_token,
        tokenResponse.expires_in,
        tokenResponse.expires_in, // ext_expires_in,
        realm,
        scopes,
    );

    const refreshTokenKey = `${homeAccountIdLowerCase}-${environment}-refreshtoken-${clientId}-${realm}`;
    const refreshTokenEntity = buildRefreshTokenEntity(homeAccountId, tokenResponse.access_token);

    // localStorage was not working, needs to be in sessionStorage
    sessionStorage.setItem(accountKey, JSON.stringify(accountEntity));
    sessionStorage.setItem(idTokenKey, JSON.stringify(idTokenEntity));
    sessionStorage.setItem(accessTokenKey, JSON.stringify(accessTokenEntity));
    sessionStorage.setItem(refreshTokenKey, JSON.stringify(refreshTokenEntity));
};
</code></pre>
<ul>
<li>Lastly, in the login function I used the /adfs link as we use on-premise ADFS and MSAL.js v2.0 and did NOT need that client_secret:</li>
</ul>
<pre><code>export const login = (cachedTokenResponse: any) =&gt; {
    let tokenResponse: any = null;
    let chainable: Cypress.Chainable = cy.visit('/'); // need to visit root to be able to store Storage against this site

    if (!cachedTokenResponse) {
        chainable = chainable.request({
            url: authority + '/adfs/oauth2/token', // was this '/oauth2/v2.0/token',
            method: 'POST',
            body: {
                grant_type: 'password',
                client_id: clientId,
                // client_secret: clientSecret,
                scope: ['profile openid'].concat(apiScopes).join(' '),
                username,
                password,
            },
            form: true,
        });
***... MORE CODE OMITTED*** 
</code></pre>
<ul>
<li>finally I ran using VSCode terminal 1 (yarn start) then terminal 2 (yarn run cypress open)</li>
</ul>
<p>TYPESCRIPT use:</p>
<ul>
<li>rename all files from .js to .ts</li>
<li>update tsconfig to include the cypress type on this line:</li>
</ul>
<pre><code>&quot;types&quot;: [&quot;node&quot;, &quot;cypress&quot;],
</code></pre>
<p>Now when I run Cypress I can navigate around my site and I am authenticated!!  Hope this helped you save an hour or two!!</p>
",https://stackoverflow.com/questions/70985977/ui-testing-using-cypress-with-authentication-to-azure-ad-using-adfs,"['azure', 'cypress', 'adfs', 'azure-ad-msal', 'ui-testing']",2243,False,5,0
LaunchedEffect not called on Box while UI testing in Jetpack Compose,"<p>I am running a simple Test on LaunchedEffect:</p>
<pre><code>@Test
fun testSomeState() {
    composeTestRule.setContent {
        SomeComposable {
            println(&quot;click $it&quot;)
        }
    }
    composeTestRule.onNodeWithTag(&quot;Zivi&quot;)
        .performClick()
        .assertExists()
}

@Composable
fun SomeComposable(onClick: (Int) -&gt; Unit) {
    var someState by remember { mutableStateOf(0) }

    Button(modifier = Modifier.testTag(&quot;Zivi&quot;).pointerInteropFilter {
        someState = when (it.action) {
            MotionEvent.ACTION_DOWN -&gt; { 1 }
            MotionEvent.ACTION_UP -&gt; { 2 }
            else -&gt; { someState  }
        }
        true

    }, onClick = { }) {}

    LaunchedEffect(someState) {
        println(&quot;LaunchedEffect someState $someState&quot;) // prints &quot;LaunchedEffect someState 0&quot; 
                                                       // and then &quot;LaunchedEffect someState 2&quot;
        if (someState == 2) { onClick(someState) }
    }
}
</code></pre>
<hr />
<h2>This works well, however, if i change Button to a Box, like this:</h2>
<pre><code>@Composable
fun SomeComposable(onClick: (Int) -&gt; Unit) {
    var someState by remember { mutableStateOf(0) }

    Box(modifier = Modifier.testTag(&quot;Zivi&quot;).pointerInteropFilter {
        someState = when (it.action) {
            MotionEvent.ACTION_DOWN -&gt; { 1 }
            MotionEvent.ACTION_UP -&gt; { 2 }
            else -&gt; { someState  }
        }
        true

    }) {}

    LaunchedEffect(someState) {
        println(&quot;LaunchedEffect someState $someState&quot;) // prints &quot;LaunchedEffect someState 0&quot;
        if (someState == 2) { onClick(someState) }
    }
}
</code></pre>
<p>Then the LaunchedEffect is not called on performClick, can anyone help me understand why?</p>
",https://stackoverflow.com/questions/71644596/launchedeffect-not-called-on-box-while-ui-testing-in-jetpack-compose,"['android', 'android-jetpack-compose', 'android-testing', 'ui-testing']",867,True,1,1
Karate UI testing open one browser instance for all test cases,"<p>I have multiple test cases for each test case it is opening new browser, how to open just one browser instance and navigate all to all Url.
In parallel execution it opens multiple browsers don't need parallel. Ecexute on test cases one by one on one chrome browser instance</p>
",https://stackoverflow.com/questions/71467719/karate-ui-testing-open-one-browser-instance-for-all-test-cases,"['karate', 'browser-automation']",19,False,1,0
UI Testing a C# ASP.NET Core 6 MVC app with Selenium,"<p>For the past few hours I've been trying to write selenium tests for an ASP.NET Core 6 MVC web app. A few weeks ago we wrote integration tests for the API using WebApplicationFactory and that worked great:</p>
<pre><code>namespace ContactBook.Tests.Common
{
    public class TestContactBookApp : WebApplicationFactory&lt;Program&gt;
    {
        public TestDb TestDb { get; set; }

        public WebApplicationFactory&lt;Program&gt; App { get; set; }

        public TestContactBookApp(TestDb testDb, string appContentRoot)
        {
            this.TestDb = testDb;

            this.App = new WebApplicationFactory&lt;Program&gt;()
                .WithWebHostBuilder(webHostBuilder =&gt;
                {
                    webHostBuilder.UseContentRoot(appContentRoot);

                    webHostBuilder.ConfigureServices(services =&gt;
                    {
                        var oldDbContext = services.SingleOrDefault(
                                descr =&gt; descr.ServiceType == typeof(ContactBookDbContext));
                        services.Remove(oldDbContext);
                        services.AddScoped&lt;ContactBookDbContext&gt;(
                            provider =&gt; this.TestDb.CreateDbContext());
                    });
                    // Use random free TCP port for the Web server
                    webHostBuilder.UseUrls(&quot;http://127.0.0.1:0&quot;);
                });
        }

        public void Dispose()
        {
            this.App.Dispose();
        }
    }
}
</code></pre>
<p>For Selenium although I am getting a <code>ERR_CONNECTION_REFUSED</code> error when trying to access the base url.</p>
<p>Here is my <code>SeleniumTestBase</code> class:</p>
<pre><code>namespace ContactBook.WebAPI.SeleniumTests
{
    public class SeleniumTestsBase
    {
        protected TestDb testDb;
        protected IWebDriver driver;
        protected TestContactBookApp testContactBookApp;
        protected HttpClient httpClient;
        protected string baseUrl;
        protected string username;
        protected string password;
        protected string phoneNumber;

        [OneTimeSetUp]
        public void OneTimeSetUpBase()
        {
            // Run the Web app in a local Web server
            this.testDb = new TestDb();
            this.testContactBookApp = new TestContactBookApp(
                this.testDb, &quot;../../../../ContactBook.WebApp&quot;);
            this.httpClient = testContactBookApp.App.CreateDefaultClient();
            //this.httpClient.
            this.baseUrl = this.httpClient.BaseAddress.ToString();
            this.username = $&quot;user{DateTime.Now.Ticks.ToString()[10..]}&quot;;
            this.password = $&quot;pass{DateTime.Now.Ticks.ToString()[10..]}&quot;;
            this.phoneNumber = &quot;+359886183166&quot;;

            // Setup the ChromeDriver
            ChromeOptions chromeOptions = new ChromeOptions();
            if (!Debugger.IsAttached)
                chromeOptions.AddArguments(&quot;headless&quot;);
            chromeOptions.AddArguments(&quot;--start-maximized&quot;);
            this.driver = new ChromeDriver(chromeOptions);

            // Set an implicit wait for the UI interaction
            this.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
        }

        [OneTimeTearDown]
        public void OneTimeTearDownBase()
        {
            // Stop and dispose the Selenium driver
            this.driver.Quit();

            // Stop and dispose the local Web server
            this.testContactBookApp.Dispose();
        }
    }
}
</code></pre>
<p>I used this page for reference to no avail:</p>
<p><a href=""https://www.benday.com/2021/07/19/asp-net-core-integration-tests-with-selenium-webapplicationfactory/"" rel=""nofollow noreferrer"">ASP.NET Core Integration Tests with Selenium</a></p>
<p><a href=""https://blog-bertrand-thomas.devpro.fr/2020/01/27/fix-breaking-change-asp-net-core-3-integration-tests-selenium/"" rel=""nofollow noreferrer"">Quick fix for integration testing with Selenium in ASP.NET Core 3.1</a></p>
<p>In one previous project (I haven't worked on it personally) my colleges use <code>IHostBuilder</code> to achieve a test server like so:</p>
<pre><code>namespace TaskBoard.Tests.Common
{
    public class TestTaskBoardApp&lt;TStartup&gt; : IDisposable where TStartup : class
    {
        private IHost host;

        public TestDb TestDb { get; set; }

        public string ServerUri { get; private set; }

        public TestTaskBoardApp(TestDb testDb, string appContentRoot)
        {
            this.TestDb = testDb;
        
            IHostBuilder hostBuilder = Host.CreateDefaultBuilder();
            hostBuilder.ConfigureWebHostDefaults(webHostBuilder =&gt;
            {
                webHostBuilder.UseContentRoot(appContentRoot);
                webHostBuilder.UseStartup&lt;TStartup&gt;();
                webHostBuilder.ConfigureServices(services =&gt;
                {
                    var oldDbContext = services.SingleOrDefault(
                        descr =&gt; descr.ServiceType == typeof(ApplicationDbContext));
                    services.Remove(oldDbContext);
                    services.AddScoped&lt;ApplicationDbContext&gt;(
                        provider =&gt; this.TestDb.CreateDbContext());
                });
                // Use random free TCP port for the Web server
                webHostBuilder.UseUrls(&quot;http://127.0.0.1:0&quot;);
            });
            this.host = hostBuilder.Build();
            this.host.Start();
            var server = this.host.Services.GetRequiredService&lt;IServer&gt;();
            var serverAddresses = server.Features.Get&lt;IServerAddressesFeature&gt;().Addresses;
            this.ServerUri = serverAddresses.Where(a =&gt; a.Contains(&quot;http://&quot;)).FirstOrDefault();
            Debug.WriteLine($&quot;Testing server started: {this.ServerUri}&quot;);
        }

        public void Dispose()
        {
            this.host.Dispose();
            Debug.WriteLine($&quot;Testing server stopped: {this.ServerUri}&quot;);
        }
    }
}
</code></pre>
<p>I tried making a somewhat similar implementation just to get a <code>A public method named 'ConfigureProduction' or 'Configure' could not be found in the 'Program' type.</code> error message.</p>
<p>I would really appreciate if someone has done this before successfully to lend a hand!</p>
",https://stackoverflow.com/questions/74131573/ui-testing-a-c-asp-net-core-6-mvc-app-with-selenium,"['c#', 'selenium', 'asp.net-core-mvc', 'asp.net-core-6.0']",295,False,0,0
How to check sent by web requests during UI testing without mocking,"<p>I perform UI testing and want to check if the UI actions lead to the correct API request. I would not like to change them. Is there a way to do that?
Thank you in advance.</p>
",https://stackoverflow.com/questions/70942235/how-to-check-sent-by-web-requests-during-ui-testing-without-mocking,['karate'],46,False,1,0
How to access webview code in VS code’s DOM for UI testing,"<p>I am trying to automate UI testing of the extension for VS Code that has certain actions brought out into the SideBarView section as webview, self-written HTML that I want to access via Selenium webdriver (I use vscode-extension-tester package that provides almost every API necessary and is fantastically helpful, btw).</p>
<p>There's no problem accessing html from VS Code's DevTools, for example a button is exposed as &quot;vscode-button&quot; tag inside a webview's &quot;iframe&quot; tag, so I assume finding it by xpath might work:</p>
<pre><code>let webElement = await driver.findElement(By.xpath('//vscode-button[contains(@onclick, &quot;loadMarkers&quot;)]'));
</code></pre>
<p>But when I run Extension host for testing, its DOM does not contain webview code, so findElement() returns &quot;undefined&quot;. If I understand correctly, it only has a reference to the webview tag with the pointer to vscode extension that handles webview content, so I have to switch to that webview somehow. Page source shows only &quot;div&quot; with webview link inside an &quot;iframe&quot;:</p>
<pre><code>&lt;div id=&quot;webview-&lt;id&gt;&quot;...
  &lt;iframe name=&quot;&lt;id&gt;&quot; class=&quot;webview ready&quot;... src=&quot;vscode-webview...;extensionId=&lt;id&gt;...;purpose=webviewView&quot;...&gt;&lt;/iframe&gt;
</code></pre>
<p>Haven't found anything in VS Code API document, currently reading about Electron webview API to understand if there are any other suggestions.</p>
<p>Vscode-extension-tester API provides switching to webview context from a different object, however. So I wondered if there is a generic way to do so.
<a href=""https://github.com/redhat-developer/vscode-extension-tester/wiki/WebView"" rel=""nofollow noreferrer"">https://github.com/redhat-developer/vscode-extension-tester/wiki/WebView</a></p>
<p>p.s. I began working on automated testing just a while ago, so I may miss something obvious (that would be great to have a solution at hand), but it looks like there are no easy ways to solve my problem at the moment. Would appreciate any help you can provide.</p>
",https://stackoverflow.com/questions/73202635/how-to-access-webview-code-in-vs-code-s-dom-for-ui-testing,"['selenium-webdriver', 'visual-studio-code', 'webview']",171,False,1,0
TestComplete:Can we integrate Automated Windows UI Testing with Azure DevOps using GitHub?,"<p>I need to integrate the Automated Windows UI Test project with the Azure DevOps pipeline and use TestComplete code from GitHub. Can't able to integrate the TestComplete Automated UI test when using GitHub.
Can we integrate TestComplete Automated UI Test with Azure DevOps?</p>
",https://stackoverflow.com/questions/73937987/testcompletecan-we-integrate-automated-windows-ui-testing-with-azure-devops-usi,"['azure-devops', 'azure-pipelines', 'devops', 'testcomplete', 'azure-devops-extensions']",127,False,0,1
Share tests them beetween several packages in Android Espresso UI testing (Kotlin),"<p>I have two packages for the Espresso tests in my project, <code>package A</code> and <code>package B</code>.<br />
<code>Package A</code> acts as default package to run tests on Jenkins, contains 100+ tests, but in specified cases I don't need to run them all, but only several from each class.</p>
<p>So, I created a <code>package B</code>, which contains selected tests from <code>Package A</code>, so it duplicates code from <code>Package A</code>, but not reusing, and when I change something in test <code>Package A</code>, I need to manually make the same changes in in <code>Package B</code>.</p>
<p>I follow Robot Pattern to write my tests, but even with it's not always share code automatically:
For example, I wrote the following code in package A, then I would just copy it to Package B:</p>
<pre><code>// package A
@Test
fun verifyWrongPasswordSnackBar(){
    login {
        verifyLoginScreen()
        setEmail(&quot;mail@example.com&quot;)
        setWrongPassword(&quot;11111&quot;)
        clickLogin()
        verifyWrongPasswordSnackbar()
    }
}
</code></pre>
<p>If I add anything to this code, like fun <code>agreeWithPrivacyTerms()</code> or change variables in <code>setEmail</code> / <code>setWrongPassword</code>  I need to do the same in Package B, manually</p>
<p>Is there any way to re-use tests in package B from package A, like:</p>
<pre><code>// package B
@Test 
fun packageBLoginScreenToastDisplaytest(){
//run verifyWrongPasswordSnackBar() test from package A
}
</code></pre>
<p>Thanks in advance, will be glad to clarify</p>
",https://stackoverflow.com/questions/72831874/share-tests-them-beetween-several-packages-in-android-espresso-ui-testing-kotli,"['android', 'package', 'android-espresso', 'android-testing']",77,False,0,0
Karate UI testing: how to prevent browser closing at the end of Scenario,"<p>I am working on UI automated tests using Karate framework. I am really enjoyng working with this great tool, but it's something that I'm trying to resolve for a while and can't find any solution.</p>
<p>I have a feature file with <strong>3 scenarios</strong> and I want to open the browser and to make login only <strong>once</strong>, before all scenarios, and to be closed only after the last scenario is finished.
In my case driver is started at separated login.feature file which is called from <strong>Background</strong> using 'callonce read('login.feature')' command. I've seen somewhere that if driver is started before scenario. In my case it's not working. What do I do wrong?</p>
",https://stackoverflow.com/questions/74478050/karate-ui-testing-how-to-prevent-browser-closing-at-the-end-of-scenario,"['automated-tests', 'webdriver', 'karate']",224,True,1,1
How can I do validate that a checkbox is selected in KARATE UI testing?,"<ul>
<li>def scr = scriptAll('assert(await driver.findElement(By.xpath(&quot;//div[5]/div/p-checkbox/div/div[2]/span&quot;)).isSelected())')</li>
<li>match scr == true</li>
</ul>
<p>I tried this way but I think logic is wrong.</p>
",https://stackoverflow.com/questions/73421442/how-can-i-do-validate-that-a-checkbox-is-selected-in-karate-ui-testing,"['javascript', 'validation', 'checkbox', 'frameworks', 'karate']",321,False,1,1
How to assert a condition pass or fail in pytest for web UI testing,"<pre><code>def test_review():
review_score = driver.find_element(By.ID, &quot;acrCustomerReviewText&quot;)
assert &quot;review_score&quot; &gt;= &quot;4&quot;
price = driver.find_element(By.ID, &quot;corePriceDisplay_desktop_feature_div&quot;)
assert &quot;price&quot; &lt;= &quot;4000&quot;
</code></pre>
<p>I want to review the rating if it's less than 4 fail the test otherwise  pass it
The second one is similar
I checked the product price if the price is more than 4000 and failed it
How do I know if it's passing or failing?</p>
",https://stackoverflow.com/questions/74503559/how-to-assert-a-condition-pass-or-fail-in-pytest-for-web-ui-testing,"['python', 'selenium', 'pytest']",158,False,0,1
"Could not load file or assembly &#39;WebDriver, Version=2.53.1.0 when using coded UI Testing","<p>Since today I get the following <strong>new</strong> Error message:</p>
<pre><code>System.IO.FileLoadException: Could not load file or assembly 'WebDriver, Version=2.53.1.0, Culture=neutral, PublicKeyToken=1c2bd1631853048f' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044) ---&gt; System.IO.FileLoadException: A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
</code></pre>
<p>Everything worked fine until yesterday and now I lost 6 out of my 7 test VMs to this error.</p>
<p>I read every documentation I could find and tried to compare the non working VMs with the the non working version and could not find a difference.</p>
<p>Suspicious is the <code>Version=2.53.1.0</code> as the current WebDriver DLL is 4.4.0. Where could the reference to this potential old DLL come from?</p>
<p>Is there a debug or logging option I could activate? A way to see which DLLs are loaded?</p>
<p>Needless to say that with only 1 out of 7 Testmachines we will not be able to meet the deadline.</p>
",https://stackoverflow.com/questions/73827221/could-not-load-file-or-assembly-webdriver-version-2-53-1-0-when-using-coded-ui,"['c#', 'visual-studio', 'coded-ui-tests', 'visual-studio-test-runner']",32,False,0,1
How can I create core data records from a data file for UI Testing?,"<p>I’m trying to create some complex UI Tests, which are dependent on data.</p>
<p>My app uses CoreData.</p>
<p>I’m assuming I’ll have to pass in some launch arguments and run some code to add this data.</p>
<p>I know that I could create some lines of code to create all the entities I need and the values for fields etc.</p>
<p>However I’d rather keep this data outside of my app and have some way to load my data via some kind of data file. I’m thinking json.</p>
<p>But obviously I’m going to need some mechanism to transform json into core data records.</p>
<p>Or maybe I’m missing some different approach which would be easier?</p>
",https://stackoverflow.com/questions/70570720/how-can-i-create-core-data-records-from-a-data-file-for-ui-testing,"['swift', 'core-data', 'xcode-ui-testing']",119,False,0,0
Xcode 14 (on Ventura): &quot;Failed to prevent system sleep during UI testing&quot; when UNIT testing,"<p>I'm running Xcode 14 beta 5 on macOS Ventura (13.0 Beta (22A5321d)) and when trying to run unit tests, not UI tests, plain old unit tests, I get this super annoying dialog when starting a test.</p>
<p>This is an SPM package, not an .xcodeproj.</p>
<p><a href=""https://i.stack.imgur.com/B3yvq.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/B3yvq.png"" alt=""enter image description here"" /></a></p>
<p>If I click details, this is shown:</p>
<pre><code>Details

Failed to prevent system sleep during UI testing. Error code: -536870211
Domain: IDEFoundationErrorDomain
Code: 1
User Info: {
    DVTErrorCreationDateKey = &quot;2022-08-17 20:06:42 +0000&quot;;
}
--


System Information

macOS Version 13.0 (Build 22A5321d)
Xcode 14.0 (21330) (Build 14A5294e)
Timestamp: 2022-08-17T22:06:42+02:00
</code></pre>
<p>Sometimes deleting derived data helps, sometimes not.</p>
<p>Any clues? I did not see this error in Xcode 14 beta 1 I think.</p>
",https://stackoverflow.com/questions/73394395/xcode-14-on-ventura-failed-to-prevent-system-sleep-during-ui-testing-when-u,['xcode14'],500,False,2,1
How to disable SIP on macOS VMs for macOS UI testing in CI/CD environment?,"<p>I have been trying to run my macOS UI tests on a remote machine(VM), and it does not work. On a local machine, it works after giving the permissions related to accessibility. After digging through, I realised that you need to have SIP disabled and add the relevant permission.</p>
<p>So, how can I disable SIP on a headless machine in a CI/CD?</p>
",https://stackoverflow.com/questions/71157609/how-to-disable-sip-on-macos-vms-for-macos-ui-testing-in-ci-cd-environment,"['macos', 'cicd', 'xcuitest']",70,True,2,1
How can I use two test methods in single Test Class for JavaFx UI testing?,"<p>I am currently facing an exception while loading the UI controller.</p>
<p>Have written two separate methods for testing client requests for a server while loading files.</p>
<p>I have start methods which loads UI controller-</p>
<pre class=""lang-java prettyprint-override""><code>@Override
public void start(Stage stage) throws IOException {
</code></pre>
<p>and test methods are as follows:</p>
<ol>
<li><p>First test</p>
<pre class=""lang-java prettyprint-override""><code>@Test
@DisplayName(&quot;load the files&quot;)
public void testRoutineA() throws URISyntaxException, NullPointerException, IOException {
</code></pre>
</li>
<li><p>Second test</p>
<pre class=""lang-java prettyprint-override""><code>@Test
public static void testRoutineB() throws IOException {
</code></pre>
</li>
</ol>
<p>Issue:</p>
<ul>
<li>testRoutineA runs fine and load the UI.</li>
<li>But when testRoutineB runs it again call the Sart method and throws exception:</li>
</ul>
<p>Exception in Async Thread ---
Failed to load FXML files.</p>
<p>Any suggestion how to use both methods ?</p>
",https://stackoverflow.com/questions/73279538/how-can-i-use-two-test-methods-in-single-test-class-for-javafx-ui-testing,"['java', 'unit-testing', 'javafx', 'junit', 'testfx']",60,False,0,0
What alternatives to Selenium WebDriver can I use for automated UI testing of a web application?,"<p>I'm working on a project that currently uses Selenium WebDriver to run automated UI tests for a web-based application. However, Selenium is no longer being approved for use on this project. My team is currently investigating alternative solutions. We need something that can be used with a  CI/CD pipeline and that supports testing for multiple browser types. It would also be great if it can be integrated with Cucumber, which we also use currently, but this is not strictly necessary. I would love to hear your suggestions for anything that we can use. Thank you in advance!</p>
",https://stackoverflow.com/questions/72607978/what-alternatives-to-selenium-webdriver-can-i-use-for-automated-ui-testing-of-a,"['selenium-webdriver', 'automated-tests', 'cucumber', 'ui-automation', 'cicd']",86,False,0,0
Making UI Test Wait For The App To Load Before Performing Other Action - UI Testing In Android,"<p>In my app, I am getting some data from firebase after the user logs in.</p>
<p>While writing the test for the app</p>
<pre><code>@Test
    public void loginAndLogoutTest() {
        //...after inputing the login details
        ViewInteraction materialButton = onView(
                allOf(withId(R.id.buttonLogin), withText(&quot;Login&quot;), isDisplayed()));
        materialButton.perform(click());

        //...The app starts loading to get some data from the database

        //...

        //...The test fails and it does not wait for the app to load before trying to press the logout

        ViewInteraction materialTextView = onView(
                allOf(withId(R.id.textViewNavLogout), withText(&quot;Logout&quot;), isDisplayed()));
        materialTextView.perform(click());

        //...
    }

</code></pre>
<p>Is it possible to make the test wait till the app fetches the data from the database and then performs the logout click after?</p>
",https://stackoverflow.com/questions/74953741/making-ui-test-wait-for-the-app-to-load-before-performing-other-action-ui-test,"['java', 'android', 'testing', 'gui-testing']",43,False,0,0
Is it possible to get combined test coverage of android Unitesting and UI testing coverage | not repeated question,"<p>I have tried using <strong>jacoco</strong> for fetching code coverage but every time i am able to get 100% success  also i have found that <strong>JacocoEverywhere</strong> is deprecated is there any other way to fetch code coverage.</p>
<p>I have gone through several stackoverflow questions not able to find the answer so raising this question.</p>
",https://stackoverflow.com/questions/73019410/is-it-possible-to-get-combined-test-coverage-of-android-unitesting-and-ui-testin,"['android', 'kotlin', 'user-interface', 'android-espresso', 'ui-testing']",109,False,1,0
How to deal with google maps during UI testing,"<p>Our company uses <a href=""https://softwareengineering.stackexchange.com/questions/358786/what-is-golden-files"">golden files</a> for our automated UI testing. It detects UI changes caused by code changes during our PR pipeline Continous Integration. However, it detects several false changes which were caused by the Map not loading properly due to internet latency.</p>
<p>For the case below, notice the white areas on the left. The testing software thought these were UI changes which are actually not and the test for this case failed even though it was supposed to pass.</p>
<p>Does anyone have any experience dealing with Google maps on any framework like Javascript, Android, or iOS when doing UI Testing?</p>
<p>Ideally, it would be best if a tiny portion of the Google map is downloaded offline during the UI testing but does the Google Maps SDK has anything for that?</p>
<p>If not, can we replace the image layer of a specific region on the map with a static offline image or can we mock the API calls done by the map to load those tiles?</p>
<p><a href=""https://i.stack.imgur.com/TWkPW.jpg"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/TWkPW.jpg"" alt=""enter image description here"" /></a></p>
",https://stackoverflow.com/questions/73655094/how-to-deal-with-google-maps-during-ui-testing,"['android', 'google-maps', 'testing', 'google-maps-api-3', 'google-maps-sdk-ios']",195,False,1,0
TestCafe headless mode - Safari,"<p>I'm evaluating TestCafe as a potential UI testing tool for our team. The target browser is Safari. Is that correct that headless tests cannot be run with Safari?</p>
",https://stackoverflow.com/questions/70802838/testcafe-headless-mode-safari,"['testing', 'automation', 'automated-tests', 'e2e-testing', 'testcafe']",371,True,0,1
How to check sent by web requests during UI testing without mocking,"<p>I perform UI testing and want to check if the UI actions lead to the correct API request. I would not like to change them. Is there a way to do that?
Thank you in advance.</p>
",https://stackoverflow.com/questions/70942235/how-to-check-sent-by-web-requests-during-ui-testing-without-mocking,['karate'],46,False,1,0
Karate Analytics,"<p>My project is required to do ui testing and to track Adobe Analytics. I know that there are options with Java libraries. But I'm willing to use Karate and combine it with Adobe Analytics. Any suggestions?</p>
",https://stackoverflow.com/questions/73692567/karate-analytics,"['java', 'adobe', 'analytics', 'karate']",35,False,1,0
How can I do UI Test automation for the UWP project of my Xamarin application,"<p>As the question says, I have a Xamarin forms application that targets Android, iOS and UWP. I am able to use Xamarin.UITests for UI testing on the Android and iOS project, but I need a frame work to help with UI testing on UWP. I found <a href=""https://blog.infernored.com/cross-platform-ui-testing-with-specflow-xamarin-and-codedui/"" rel=""nofollow noreferrer"">this</a> and while it looks helpful, its quite hard to understand, it seems old, so not sure if all of it is still up to date, and the third step in the process is missing (page is 404).</p>
<p>I've also heard of WebDriver, but cannot find any straight forward documentation for how to use it for Xamarin.UWP.</p>
<p>Any ideas on how I can test for UWP?</p>
",https://stackoverflow.com/questions/73889109/how-can-i-do-ui-test-automation-for-the-uwp-project-of-my-xamarin-application,"['xamarin.uwp', 'gui-testing']",57,False,0,1
"Jenkin UI, Filter by name (with regular expression) Regular expression does not detect the branch named with forward slash","<p>Problem:</p>
<p>Filter by name (with regular expression)
Regular expression</p>
<p>Given Expression: Attached the image.</p>
<p>It is recognising 'TestJenkins' and 'testJenkins' but it is not matching 'dev/ui-testing'</p>
<p>any idea what is wrong in regex.</p>
<p>Thanks in advance!</p>
<p><a href=""https://i.stack.imgur.com/rfnno.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/rfnno.png"" alt=""enter image description here"" /></a></p>
",https://stackoverflow.com/questions/71290442/jenkin-ui-filter-by-name-with-regular-expression-regular-expression-does-not,"['jenkins', 'jenkins-plugins', 'devops']",186,False,0,0
Webdriverio iOS restart app with processArguments,"<p>I have iOS app which implemented UI testing with Appium.
And when I want to restart app with this code, processArguments are lost.
Could anyone tell me how to restart app without losing processArguments or pass processArguments when restart app?</p>
<pre><code>await driver.terminateApp(bundleId);
await driver.activateApp(bundleId);
</code></pre>
",https://stackoverflow.com/questions/71965496/webdriverio-ios-restart-app-with-processarguments,"['javascript', 'ios', 'webdriver', 'appium', 'webdriver-io']",487,True,1,1
Junit5 Cucumber &quot;No definition found for...&quot; in .feature file,"<p>I'm trying to create a simple Junit5-Cucumber project (in Eclipse) that would be used for UI testing.</p>
<p>I took reference from this repo:<a href=""https://github.com/cucumber/cucumber-java-skeleton"" rel=""nofollow noreferrer"">https://github.com/cucumber/cucumber-java-skeleton</a></p>
<p>Issue: No definition found for <code>Open the Chrome and launch the application</code> (error happens to the <code>Given</code>, <code>When</code> and <code>Then</code> statements) in the <code>test_features.feature</code> file.</p>
<pre><code># test_features.feature
Feature: Reset functionality on login page of Application

    Scenario: Verification of Reset button
    
       Given Open the Chrome and launch the application
        
       When Enter the username and password
        
       Then Reset the credentials
</code></pre>
<pre><code># RunCucumberTest.java
package lpms.cucumber;
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;

@Suite
@IncludeEngines(&quot;cucumber&quot;)
@SelectClasspathResource(&quot;lpms/cucumber&quot;)
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = &quot;pretty&quot;)
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = &quot;lpms.cucumber&quot;)
public class RunCucumberTest {
}
</code></pre>
<pre><code># StepDefinitions.java
package lpms.cucumber;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

public class StepDefinitions {
    @Given(&quot;^Open the Chrome and launch the application$&quot;)
    public void open_the_chrome_and_launch_the_application() throws Throwable
    {
        System.out.println(&quot;This step opens the chrome and launches the application&quot;);      
    }
    
    @When(&quot;^Enter the username and password$&quot;)
    public void enter_the_username_and_password() throws Throwable
    {
        System.out.println(&quot;This step enters the username and password on the login page&quot;);     
    }
     
    @Then(&quot;^Reset the credentials$&quot;)
    public void reset_the_credential() throws Throwable
    {
        System.out.println(&quot;This step clicks on the reset button.&quot;);
    }
}
</code></pre>
<p>Project Structure</p>
<p><a href=""https://i.stack.imgur.com/Q6KVd.png"" rel=""nofollow noreferrer"">IMAGE OF MY PROJECT STRUCTURE</a></p>
",https://stackoverflow.com/questions/70753052/junit5-cucumber-no-definition-found-for-in-feature-file,['cucumber-junit'],912,True,1,2
How to Extract text from Toast in android for validation?,"<p>I am using espresso for ui testing of an android app. It has feature of logging in. While logging in, if user enters wrong username or password, a toast appears saying &quot;Incorrect username or password&quot;. I want that text for validation. I am writing the tests in android test folder.</p>
<p>I am new to android app testing. Need help!</p>
",https://stackoverflow.com/questions/74859301/how-to-extract-text-from-toast-in-android-for-validation,"['android', 'android-espresso', 'android-toast']",66,True,0,1
Run a cypress command if content is present and skip if content is not present,"<p>Hi I am working with cypress for UI testing. Based on user we do have additional button on the page.</p>
<p>Is there a way cypress can look for a button and run the commands if button is present and skip the command if button is absent thus preventing from element not found error.</p>
<pre><code>&lt;div class=&quot;btn btn-success&quot; id=&quot;editButton&quot;&gt;Edit&lt;/div&gt;

</code></pre>
<p>Cypress code is</p>
<pre><code>    if (!cy.get('div[id=editButton]')) {
        this.skip();
    } else {
        cy.get('div[id=editButton]').click();
    }
   
</code></pre>
<p>And yet cypress throws element not found error.</p>
",https://stackoverflow.com/questions/71149018/run-a-cypress-command-if-content-is-present-and-skip-if-content-is-not-present,"['javascript', 'cypress', 'ui-automation']",1063,True,4,5
Selenium- How to read a PDF file with current user context,"<p>I am using selenium for SharePoint UI testing, and I have test scenario where I would need to read and verify the PDF content. but when I use the following code I get. Error &quot;:java.io.IOException: Server returned HTTP response code: 401 for URL http://******.com/pdf&quot;</p>
<p><strong>So I would need help on reading the PDF file with current User context.</strong></p>
<pre><code>String GetURL = driver.getCurrentUrl();
    URL TestURL = new URL(GetURL);
    
    BufferedInputStream TestFile = new BufferedInputStream(TestURL.openStream());
    PDFParser TestPDF = new PDFParser((RandomAccessRead) TestFile);
    TestPDF.parse();
    String TestText = new PDFTextStripper().getText(TestPDF.getPDDocument());
    
    Assert.assertTrue(TestText.contains(&quot;Open the setting.xml, you can see it is like this&quot;));
</code></pre>
",https://stackoverflow.com/questions/73331683/selenium-how-to-read-a-pdf-file-with-current-user-context,"['java', 'selenium', 'sharepoint']",41,False,0,0
Can you use Squish for Android with other IDEs?,"<p>I find Squish IDE extremely clunky and counter intuitive. I wanted to try Squish testing but I would like to use some other tools to write scripts, like VSCode or PyCharm. Is it possible? Could you point me to some resources that would introduce me to this set up?</p>
<p>Or maybe some other solutions than Squish to allow UI testing for Qt apps on Android?</p>
",https://stackoverflow.com/questions/73637971/can-you-use-squish-for-android-with-other-ides,"['python', 'qt', 'squish']",168,True,1,1
I cannot Select an Element with the AndroidFindBy,"<p>I am fairly new to Appium and i am currently working on UI testing of an application. I want to click an element but it is not visible until you scroll down the page.</p>
<p>I have tried using the command below but it does not work for me</p>
<p>driver.findElement(By.xpath(&quot;new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(&quot;WebView&quot;).instance(0))&quot;)).click();</p>
",https://stackoverflow.com/questions/74318071/i-cannot-select-an-element-with-the-androidfindby,"['selenium', 'selenium-webdriver', 'intellij-idea', 'appium-android', 'appium-java']",212,True,1,1
How do I automate a swipe from bottom to top of an iOS app in Xcode?,"<p>I am new to automating gestures with Xcode - I would like to automate simple swipe gesture from the bottom of the screen to the top, so a can have a repeatable gesture to profile.</p>
<p>I am trying to follow this example, but the gesture is more than I need: <a href=""https://jrwilliamsios438.medium.com/automated-ui-testing-in-swift-ios-46e1c9993316"" rel=""nofollow noreferrer"">https://jrwilliamsios438.medium.com/automated-ui-testing-in-swift-ios-46e1c9993316</a></p>
<p>How do I automate a swipe from bottom to top of an iOS app in Xcode?</p>
",https://stackoverflow.com/questions/72545396/how-do-i-automate-a-swipe-from-bottom-to-top-of-an-ios-app-in-xcode,"['ios', 'xcode']",42,False,1,0
Why does IIS Express not let me browse my website from my C# code,"<p>I want to start IIS Express from within C# (to run UI Tests)</p>
<p>I have an MVC website that lives in &quot;D:\GitHub\myProj\net5.Proj.Ui&quot; - if I debug it within Visual Studio, the website runs perfectly well. Now I want to do some UI testing with selenium</p>
<p>My code starts IIS Express</p>
<pre><code>var applicationPath = @&quot;D:\GitHub\myProj\net5.Proj.Ui\bin\Debug\net6.0\&quot;;            
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
var _iisProcess = new Process();
_iisProcess.StartInfo.FileName = programFiles + @&quot;\IIS Express\iisexpress.exe&quot;;
_iisProcess.StartInfo.Arguments = $&quot;/path:{ applicationPath} /port:5000&quot;;
_iisProcess.EnableRaisingEvents = true;
_iisProcess.Start();
_iisProcess.WaitForExit();
</code></pre>
<p>The output gives me</p>
<pre><code>Copied template config file 'C:\Program Files\IIS Express\AppServer\applicationhost.config' to 'C:\Users\Dave\AppData\Local\Temp\iisexpress\applicationhost2022715206710.config'
Updated configuration file 'C:\Users\Dave\AppData\Local\Temp\iisexpress\applicationhost2022715206710.config' with given cmd line info.
Starting IIS Express ...
Successfully registered URL &quot;http://localhost:5000/&quot; for site &quot;Development Web Site&quot; application &quot;/&quot;
Registration completed
IIS Express is running.
Enter 'Q' to stop IIS Express
Request started: &quot;GET&quot; http://localhost:5000/
Response sent: http://localhost:5000/ with HTTP status 403.14
</code></pre>
<p>When I open the browser, and nagivate to http://localhost:5000/ I get a 403 error, and I'm sure why</p>
",https://stackoverflow.com/questions/72999246/why-does-iis-express-not-let-me-browse-my-website-from-my-c-code,"['c#', 'iis-express']",229,False,2,0
unknown error: DevToolsActivePort file doesn&#39;t exist launching ChromeDriver using robot framework with headless in Docker,"<p>I have robot framework which will try to run the UI testing in headless mode. But when we run the robot framework inside Docker container, we got the below error</p>
<blockquote>
<p>WebDriverException: Message: unknown error: Chrome failed to start:
exited abnormally. (unknown error: DevToolsActivePort file doesn't
exist) (The process started from chrome location
/usr/bin/google-chrome is no longer running, so ChromeDriver is
assuming that Chrome has crashed.)</p>
</blockquote>
<p><strong>Dockerfile:</strong></p>
<pre><code>FROM python:3.8

ENV JAVA_OPTS &quot;-Dlog4j.formatMsgNoLookups=true&quot;
ENV LOG4J_FORMAT_MSG_NO_LOOKUPS=true
ENV WAIT_VERSION 2.7.2

#Install Google Chrome
RUN echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' &gt; /etc/apt/sources.list.d/chrome.list
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN set -x &amp;&amp; apt-get update &amp;&amp; apt-get install -y xvfb google-chrome-stable

#Install Chrome Driver
RUN BROWSER_MAJOR=$(google-chrome --version | sed 's/Google Chrome \([0-9]*\).*/\1/g') &amp;&amp; \
    wget https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${BROWSER_MAJOR} -O chrome_version &amp;&amp; \
    wget https://chromedriver.storage.googleapis.com/`cat chrome_version`/chromedriver_linux64.zip &amp;&amp; \ 
    unzip chromedriver_linux64.zip &amp;&amp; \
    mv chromedriver /usr/local/bin/

ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$WAIT_VERSION/wait /wait
RUN chmod +x /wait

CMD [&quot;/bin/bash&quot;]
</code></pre>
<p>RobotFramework resource details</p>
<pre><code>##### Headless Browser ##########
    ###### For Headless #######
    ${chrome options} =     Evaluate    selenium.webdriver.ChromeOptions()
    ...                     modules=selenium, selenium.webdriver
    Call Method    ${chromeOptions}    add_experimental_option    prefs    ${prefs}
    Call Method    ${chrome_options}   add_argument    headless
    Call Method    ${chrome_options}   add_argument    disable-gpu
    Call Method    ${chrome_options}   add_argument    --ignore-certificate-errors
    ${var}=     Call Method     ${chrome_options}    to_capabilities 
    Create Webdriver   driver_name=Chrome   alias=google   chrome_options=${chrome_options}     
    Go To   ${environment.url}
    Maximize Browser Window 
</code></pre>
<p>How to fix this issue?</p>
",https://stackoverflow.com/questions/71704028/unknown-error-devtoolsactiveport-file-doesnt-exist-launching-chromedriver-usin,"['docker', 'selenium', 'google-chrome', 'selenium-chromedriver', 'robotframework']",4572,True,1,1
How to get code coverage for Compose UI tests?,"<p>I'm now somewhat familiar with UI testing within Jetpack Compose thanks to the extensive <a href=""https://developer.android.com/jetpack/compose/testing"" rel=""noreferrer"">Android Documentation</a>, but I can't make Android Studio to run Compose tests with coverage. We are currently using Jacoco as coverage tool to generate the reports, but according to this <a href=""https://github.com/jacoco/jacoco/issues/1208"" rel=""noreferrer"">Github issue</a> it does not look like coverage for Compose is a priority for the team (sadly :S).</p>
<p>As we don't want to keep UI tests aside when evaluating code coverage, is there any way to enable code coverage in Android Studio for Compose tests, either using Android Studio or an external tool/library?</p>
",https://stackoverflow.com/questions/70762398/how-to-get-code-coverage-for-compose-ui-tests,"['android-jetpack-compose', 'android-jetpack-compose-testing']",993,False,12,0
"When inputting values for UI test, the test randomly omits putting decimal point","<p>I am using selenium webdriver in my UI testing framework where I fill forms, the double values are stored in string and inputted in the &quot;amount&quot; field. But the test randomly sometimes omits the decimal point so instead of inputting 12.37 it inputs 1237 causing my tests to fail.
I am using below code to generate random double numbers in string:
<code>Random r = new Random(); double randomValue = rangeMin + (rangeMax - rangeMin) * r.nextDouble(); return String.format(&quot;%,.2f&quot;, randomValue);</code></p>
<p>And to input value:</p>
<p><code>driverActions.clickAndSendKeys(driver,&quot;Max Spend Textbox&quot;, maxSpendTextBox, amount)</code></p>
<p>The test out of 10 runs, it randomly omits decimal point in atleast 3 runs</p>
",https://stackoverflow.com/questions/73449024/when-inputting-values-for-ui-test-the-test-randomly-omits-putting-decimal-point,"['java', 'selenium-webdriver', 'double', 'ui-testing']",7,False,0,0
How google presents different language in simulator than what is set in it,"<p>I am trying to get some specific (english) language for google content in iOS simulator. I need it to implement some UI testing that uses OIDC google provider and presents google authentication in browser.</p>
<p>So I reset simulator content and settings, I checked region to be USA, I set location to be Apple USA, still I open google.com and see language of my local region in Europe. How is that possible ? Can I somehow have english all the time in iOS simulator ?</p>
",https://stackoverflow.com/questions/74363191/how-google-presents-different-language-in-simulator-than-what-is-set-in-it,"['ios', 'simulator']",7,False,0,0
Does XCUIElement represent a query rather than a specific element?,"<p>This example is pretty contrived, but it illustrates the behavior. I know you can use <code>.accessibilityIdentifier</code> to uniquely identify a control, but I'm just trying to better understand the interplay between <code>XCUIElement</code> and <code>XCUIElementQuery</code>.</p>
<p>Let's say you have an app like this:</p>
<pre><code>import SwiftUI

struct ContentView: View {
    @State var showRedButton = true

    var body: some View {
        VStack {
            if showRedButton {
                Button(&quot;Click me&quot;) {
                    showRedButton = false
                }
                .background(.red)
            }
            else {
                HStack {
                    Button(&quot;Click me&quot;) {
                        showRedButton = true
                    }
                    .background(.blue)
                    Spacer()
                }
            }
        }
    }
}
</code></pre>
<p>And you are UI testing like this:</p>
<pre><code>import XCTest

final class MyAppUITests: XCTestCase {
    func testExample() throws {
        let app = XCUIApplication()
        app.launch()
        
        print(app.debugDescription)
        
        // At this point, the Element subtree shows a single Button:
        // Button, 0x14e40d290, {{162.3, 418.3}, {65.3, 20.3}}, label: 'Click me'
        
        let btn = app.buttons[&quot;Click me&quot;]

        btn.tap() // &lt;-- This tap makes the red button disappear and shows the blue button

        print(app.debugDescription)
        
        // Now, the Element subtree shows a single Button that has a different ID
        // and different x-y coordinates:
        // Button, 0x15dc12e50, {{0.0, 418.3}, {65.3, 20.3}}, label: 'Click me'
        
        btn.tap() // &lt;-- This tap now works on the blue button?? Without requerying?
        
        print(app.debugDescription)

        // The red button reappears, but with a different ID (which makes sense).
    }
}

        
</code></pre>
<p>Why does the second tap work, even though it's a different control? This must mean that SwiftUI is automatically re-running the <code>XCUIElementQuery</code> to find the button that matches &quot;Click me&quot;. Apparently the variable <code>btn</code> isn't linked to the control with the ID 0x14e40d290. Does this mean <code>XCUIElement</code> actually represents an <code>XCUIElementQuery</code>?        I expected it to require me to explicitly re-run the query like this,</p>
<pre><code>btn = app.buttons[&quot;Click me&quot;]
</code></pre>
<p>prior to running the 2nd tap, or the tap would've said that <code>btn</code> was no longer available.</p>
<p>The final print of the Element subtree shows that the red button has a different ID now. This makes sense, because when SwiftUI redraws the red button, it's not the same instance as the last time. This is explained well in the WWDC videos. Nevertheless, at the moment I connected the variable &quot;btn&quot; to the control, I thought there was a tighter affiliation. Maybe UI testing has to behave this way because SwiftUI redraws controls so frequently?</p>
",https://stackoverflow.com/questions/74721857/does-xcuielement-represent-a-query-rather-than-a-specific-element,"['unit-testing', 'swiftui']",22,False,0,0
Android Compose App Crashes during UI Testing (Instrumented Tests),"<p>I'm following Android Studio's Documentation for learning Kotlin and Jetpacks Compose. For Unit 2, Pathway 3, we are supposed to practice writing both local tests and instrumented tests for the Tip Calculator App that was developed.</p>
<p>When I manually tested the App, it works but it fails the Instrumented Test as the entire app closes during UI Testing. As a result, I encounter an Assertion Error,</p>
<pre><code>java.lang.AssertionError: Failed: assertExists.
Reason: Expected exactly '1' node but could not find any node that satisfies: (Text + EditableText contains 'Tip Amount: $2.00' (ignoreCase: false))

at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:162)
at androidx.compose.ui.test.SemanticsNodeInteraction.assertExists(SemanticsNodeInteraction.kt:137)
at androidx.compose.ui.test.SemanticsNodeInteraction.assertExists$default(SemanticsNodeInteraction.kt:136)
at com.example.tipcalculator.TipCalculatorInstrumentedTestUI.calculate_20_percent_tip(TipCalculatorInstrumentedTestUI.kt:46)
</code></pre>
<p>Does anyone know why this maybe happening? I have attached both my Tip Calculator App Code and Instrumented Tests codes below:</p>
<ol>
<li>Instrumented Tests</li>
</ol>
<pre><code>package com.example.tipcalculator

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performTextInput
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.example.tipcalculator.ui.theme.TipCalculatorTheme

import org.junit.Test
import org.junit.Rule
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
 * Instrumented test, which will execute on an Android device.
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
@RunWith(AndroidJUnit4::class)
class TipCalculatorInstrumentedTestUI {
    @get: Rule
    val composeTestRule = createComposeRule()

    // Compiler knows @Test in androidTest refers to Instrumented Tests, while in Test Directory refers to Local Tests
    @Test
    fun calculate_20_percent_tip() {
        // Set the UI Content, Code looks similar to Main Activity SetContent where we render the Screen and App
        composeTestRule.setContent {
            TipCalculatorTheme {
                TipCalculatorScreen()
            }
        }

        // Accessing the UI Component as a Node to access its particular text with onNodeWithText() method to access TextField Composable
        composeTestRule.onNodeWithText(&quot;Bill Amount&quot;)
            .performTextInput(&quot;10&quot;)     // Pass in the Value of the Text that we wants to populate it with

        // Apply Same Approach for Tip Percentage
        composeTestRule.onNodeWithText(&quot;Tip (%)&quot;)
            .performTextInput(&quot;20&quot;)

        // Use Assertion to ensure that the Text Composable reflects the accurate Tip to be given
        composeTestRule.onNodeWithText(&quot;Tip Amount: $2.00&quot;).assertExists()
    }
}
</code></pre>
<ol start=""2"">
<li>Application Code</li>
</ol>
<pre><code>package com.example.tipcalculator

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.StringRes
import androidx.annotation.VisibleForTesting
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.tipcalculator.ui.theme.TipCalculatorTheme
import java.text.NumberFormat
import kotlin.math.round

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            TipCalculatorTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colors.background
                ) {
                    TipCalculatorScreen()
                }
            }
        }
    }
}

@Composable
fun TipCalculatorScreen() {
    // Mutable State that receives 0 as a parameter wrapped in a State Object, making its value observable
    var amountInput by remember {
        // Importing remember setter and getter functions allows us to read and set amountInput
        mutableStateOf(&quot;&quot;)
    }

    // Mutable State for Tip
    var tipInput by remember {
        mutableStateOf(&quot;&quot;)
    }

    // Variable to remember State of the Switch
    var roundUp by remember {
        mutableStateOf(false)
    }

    // Interface to Control Focus in Compose
    val focusManager = LocalFocusManager.current

    // Convert to Double or a Null. If Null, return 0 after the Elvis Operator
    val amount = amountInput.toDoubleOrNull() ?: 0.0
    val tipPercentage = tipInput.toDoubleOrNull() ?: 0.0
    
    // Calculate Tip
    val tip = CalculateTip(amount = amount, tipPercent = tipPercentage, roundUp = roundUp)

    Column(
        verticalArrangement = Arrangement.spacedBy(8.dp),
        modifier = Modifier
            .padding(32.dp)
    ) {
        // Screen Title
        Text(
            text = stringResource(id = R.string.calculate_tip),
            fontSize = 24.sp,
            modifier = Modifier
                .align(Alignment.CenterHorizontally)
        )

        Spacer(modifier = Modifier.height(16.dp))
        // Text Field for User
        // Pass the Hoisted State back into the Child Function
        EditNumberField(
            value = amountInput,
            onValueChange = { amountInput = it },
            label = R.string.bill_amount,
            keyboardOptions = KeyboardOptions(
                imeAction = ImeAction.Next,
                keyboardType = KeyboardType.Number
            ),
            keyboardActions = KeyboardActions(
                // Move Focus downwards to the next composable when the Next Button is clicked
                onNext = {
                    focusManager.moveFocus(FocusDirection.Down)
                }
            )
        )

        // Input Field for Tip Percentage
        EditNumberField(
            label = R.string.how_was_the_service,
            keyboardOptions = KeyboardOptions(
                keyboardType = KeyboardType.Number,
                imeAction = ImeAction.Done
            ),
            keyboardActions = KeyboardActions(
                // Closes the Keyboard when Done is pressed
                onDone = { focusManager.clearFocus() }
            ),
            value = tipInput,
            onValueChange = { tipInput = it }
        )

        // Rounding Function
        RoundTipRow(
            // Setting Initial State
            roundUp = roundUp,
            // Updating the State when the Switch is clicked
            onRoundUpChanged = { roundUp = it }
        )

        Spacer(modifier = Modifier.height(24.dp))

        // Display the Tip Amount to be given
        Text(
            // Can use tip to sub into placeholder as the String has a %s placeholder
            text = stringResource(id = R.string.tip_amount, tip),
            fontSize = 20.sp,
            fontWeight = FontWeight.Bold,
            modifier = Modifier
                .align(Alignment.CenterHorizontally)
        )
    }

}

@Composable
fun EditNumberField(
    // Hoist the State by introducing 2 Parameters
    @StringRes label: Int,      // To indicate that it is meant to be a String Resource
    keyboardOptions: KeyboardOptions,
    keyboardActions: KeyboardActions,
    value: String,
    onValueChange: (String) -&gt; Unit,     // Takes a string as input but has no output
    modifier: Modifier = Modifier
) {
    TextField(
        value = value,     // Set to Empty String; Since TextBox that displays the Value
        onValueChange = onValueChange, // Set to Empty Lambda Function; Callback that is triggered when User enters text
        label = { Text(text = stringResource(label))}, // Using Label instead of Hardcoding
        modifier = Modifier
            .fillMaxWidth(),
        singleLine = true,       // Ensures text box is a single horizontal textbox that is scrollable
        keyboardOptions = keyboardOptions, // Changing the look of the keyboard
        keyboardActions = keyboardActions   // Functionality for the Action Buttons i.e. Next/Done
    )
}

// Rounding Tip Switch Function
@Composable
private fun RoundTipRow(
    modifier: Modifier = Modifier,
    // Allowing us to hoist the state of the switch
    roundUp: Boolean,
    onRoundUpChanged: (Boolean) -&gt; Unit
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .size(48.dp),
        verticalAlignment = Alignment.CenterVertically
    ) {
        // Text for Rounding Tip
        Text(text = stringResource(id = R.string.round_up_tip))
        
        Switch(
            // Determines whether the Switch is Checked, i.e. the Current State
            checked = roundUp,
            // Callback called when the Switch is clicked
            onCheckedChange = onRoundUpChanged,
            modifier = Modifier
                .fillMaxWidth()
                .wrapContentWidth(Alignment.End),
            colors = SwitchDefaults.colors(
                // Bad Practice since we are hardcoding the color and will be affected if Dark Mode is implemented for example
                uncheckedThumbColor = Color.DarkGray
            )
        )

    }
    
}

// Calculate Tip; Cannot be Private or the Local Tests will not have access to them
@VisibleForTesting      // Makes the Function Public but only for Testing purposes
internal fun CalculateTip(
    amount: Double,
    tipPercent: Double = 15.0,
    roundUp: Boolean
): String {
    var tip = tipPercent / 100 * amount

    if (roundUp == true) {
        // Rounding Up
        tip = kotlin.math.ceil(tip)
    }
    // After calculating the tip, format and display the tip with the Number Class
    return NumberFormat.getCurrencyInstance().format(tip)
}

@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
    TipCalculatorTheme {
        TipCalculatorScreen()
    }
}
</code></pre>
<p>Thank you</p>
",https://stackoverflow.com/questions/74725792/android-compose-app-crashes-during-ui-testing-instrumented-tests,"['android', 'unit-testing', 'kotlin', 'android-jetpack-compose']",619,False,0,1
Why am i getting this exception in firebase crashlytics? IllegalStateException : UiAutomation not connected,"<p><a href=""https://i.stack.imgur.com/eCmOQ.jpg"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/eCmOQ.jpg"" alt=""enter image description here"" /></a>I know that Google console runs Uiautomation tests(prelaunch).
However crash logs that i receive in firebase crashlytics do not seem to be related to the prelaunch process, because this exception happens in previous versions of our service.</p>
<p>Is this something related to hacking?? Ex) someone trying to hack our app by download our apk and running ui testings using adb commands?</p>
<p>Btw, about hundred logs were reported in short period of time.</p>
<p>I tried using adb commands and emulator to run our app’s ui testing to simulate the crash, however could not figure out.</p>
",https://stackoverflow.com/questions/74326804/why-am-i-getting-this-exception-in-firebase-crashlytics-illegalstateexception,"['android', 'firebase', 'crash', 'crashlytics', 'android-uiautomator']",157,False,0,0
Run MAVEN UI test on Azure devops deployment group,"<p>I have an Azure pipeline that runs a Maven UI test on a deployment group on a local server, the issue is that the test runs a headless test, but we need to make it UI visual test. I have found some articles that help the self-hosted agent solve this issue as below
<a href=""https://learn.microsoft.com/en-us/azure/devops/pipelines/test/ui-testing-considerations?view=azure-devops&amp;tabs=mstest#visible-ui-testing-using-microsoft-hosted-agents:%7E:text=Visible%20UI%20testing%20using%20self%2Dhosted%20Windows%20agents"" rel=""nofollow noreferrer"">Visible UI testing</a> but for the deployment group I could not find any related part.
how could I run a UI test for Maven (Not just selenium tests) on the azure Deployment group with Visible UI</p>
",https://stackoverflow.com/questions/73386525/run-maven-ui-test-on-azure-devops-deployment-group,"['selenium', 'maven', 'azure-devops', 'azure-pipelines', 'azure-devops-deploymentgroups']",175,False,0,1
Apple Watch interaction with Home Screen,"<p>I am automating Apple Watch ui testing and currently I stuck with the problem interacting with Apple Watch Home Screen (e.g. tap, press, scroll, etc.)
I know that testing is happening in the sandbox of the app under test, but I need to interact with the elements on Home Screen when the app under test is running on the background.
I know that Appium does similar thing to iPhone's Home Screen via &quot;com.apple.springboard&quot; which is the app, that manages iPhone's Home Screen, but what about Apple Watch? Is there a way I can interact with Apple Watch Home Screen?</p>
",https://stackoverflow.com/questions/71482715/apple-watch-interaction-with-home-screen,"['ios', 'apple-watch', 'xctest', 'homescreen', 'xcuitest']",82,False,0,1
How to retrieve a random value from an array that has values separate by a new line,"<p>I am a complete newbie at JS and currently using it in a testing capacity along with the Karate framework to perform some UI testing. I am having the following problem:</p>
<p>There is a dropdown that has the following HTML:</p>
<pre class=""lang-html prettyprint-override""><code>&lt;select class=id=&quot;CarId&quot; name=&quot;CarId&quot; aria-describedby=&quot;CarId-error&quot; aria-invalid=&quot;false&quot; xpath=&quot;1&quot;&gt;
&lt;option value=&quot;1&quot;&gt;Mercedes&lt;/option&gt;
&lt;option value=&quot;2&quot;&gt;BMW&lt;/option&gt;
&lt;option value=&quot;3&quot;&gt;Lexus&lt;/option&gt;
&lt;option value=&quot;4&quot;&gt;Honda&lt;/option&gt;
&lt;option value=&quot;5&quot;&gt;Toyota&lt;/option&gt;
&lt;option value=&quot;6&quot;&gt;VW&lt;/option&gt;
&lt;/select&gt;
</code></pre>
<p>I used the following Karate method to get all text values under the dropdown:</p>
<pre><code>def grabValues = scriptAll('#CarId', '_.textContent')
</code></pre>
<p>Once printed, the array look like this:</p>
<pre class=""lang-js prettyprint-override""><code>[
  &quot;Mercedes\nBMW\nLexus\nHonda\nToyota\nVW\n&quot;
]

console.log(Math.floor(Math.random() * (grabValues.length-1)))
</code></pre>
<p>When printed, it keeps giving me 0.0. I am assuming this is because the array contains new lines vs comma delimitated? If so, how can I get rid of the new lines and replace with commas?</p>
",https://stackoverflow.com/questions/71074597/how-to-retrieve-a-random-value-from-an-array-that-has-values-separate-by-a-new-l,"['javascript', 'karate']",89,True,0,2
Where can I find the source code for Swift XCUIElement extensions?,"<p>I am working on UI testing for an iOS app. I would like to create a custom extension for the <code>tap()</code> method, and would like to see the original implementation.</p>
<p>I tried stepping into the function in Xcode, but wasn't able to find the source. I found some source code for the XCTest core library <a href=""https://github.com/apple/swift-corelibs-xctest"" rel=""nofollow noreferrer"">here</a>, but I am having trouble locating where the XCUIElement extensions are defined. I tried searching GitHub for <code>func tap(withNumberOfTaps numberOfTaps: Int, numberOfTouches: Int)</code>, but didn't seem to find any Apple/Swift repositories containing this extension definition.</p>
<p>Specifically, I would like to see the source code for <a href=""https://developer.apple.com/documentation/xctest/xcuielement/1618671-tap"" rel=""nofollow noreferrer"">this extension</a>.</p>
",https://stackoverflow.com/questions/74340952/where-can-i-find-the-source-code-for-swift-xcuielement-extensions,"['ios', 'swift', 'xcode', 'uitest']",56,False,0,0
Menu Bar Popover is missing from application&#39;s elements tree on macOS,"<p>I'm currently trying to write simple UI Tests for an App that comes with a popover in the macOS menu bar. One of the tests is supposed to open the menu bar popover and interact with its content. The problem is that the content seems to be completely absence from the application's element tree.</p>
<p>I'm creating the pop-up like so:</p>
<pre><code>let view = MenuBarPopUp()

self.popover.animates = false
self.popover.behavior = .transient
self.popover.contentViewController = NSHostingController(rootView: view)
</code></pre>
<p>…and show/hide it on menu bar, click like this:</p>
<pre><code>if let button = statusItem.button {
  button.image = NSImage(named: NSImage.Name(&quot;MenuBarButtonImage&quot;))
  button.action = #selector(togglePopover(_:))
}

@objc func togglePopover(_ sender: AnyObject?) {
  if self.popover.isShown {
    popover.performClose(sender)
  } else {
    openToolbar()
  }
}

func openToolbar() {
  guard let button = menuBarItem.menuBarItem.button else { return }
  self.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
  NSApp.activate(ignoringOtherApps: true)
}
</code></pre>
<p>When I dump the element tree, the popover is not present:</p>
<pre><code>[…]
MenuBar, 0x7fef747219d0, {{1089.0, 1.0}, {34.0, 22.0}}
      StatusItem, 0x7fef74721b00, {{1089.0, 1.0}, {34.0, 22.0}}
[…]
</code></pre>
<p>Everything works when I compile the app and click around, I just can't make it work when it comes to automated UI testing. Any ideas?</p>
",https://stackoverflow.com/questions/72088213/menu-bar-popover-is-missing-from-applications-elements-tree-on-macos,"['swift', 'macos', 'accessibility', 'popover', 'menubar']",152,True,0,1
Why doesn&#39;t Next.js router work when tested in Jest?,"<p>I am rendering a component that uses Next.js router.</p>
<p>When rendering in jsdom using Jest/Testing Library via Testing Library's <code>render</code> method, the router always returns <code>null</code>.</p>
<p>For example, returning this component in Jest</p>
<pre><code>const DashboardSidebar: FC&lt;DashboardSidebarProps&gt; = (props) =&gt; {
  const { onMobileClose, openMobile } = props;
  const router = useRouter();
  const { user } = useAuth();

  useEffect(() =&gt; {
    if (openMobile &amp;&amp; onMobileClose) {
      onMobileClose();
    }
  }, [router.pathname]);
</code></pre>
<p>}</p>
<p>will give the error message</p>
<pre><code>TypeError: Cannot read property 'pathname' of null

      145 |       onMobileClose();
      146 |     }
    &gt; 147 |   }, [router.pathname]);
</code></pre>
<p>Same goes for <code>router.isReady</code>. router is <code>null</code>.</p>
<p>I am assuming that the rendering of the component in to jsdom will run the router, since the router is defined within the component.</p>
<p>I just have to make the router run so that components will render content, and I do not want to test its functionality; I am UI testing, so implementation details are unnecessary.</p>
<p>How does Nextjs router work under the hood, and why isn't it running, and how can I make the router run?</p>
",https://stackoverflow.com/questions/71776609/why-doesnt-next-js-router-work-when-tested-in-jest,"['javascript', 'node.js', 'reactjs', 'unit-testing', 'next.js']",2231,False,1,0
"How do I import with Java &amp; Intellij a method from ProjectA to ProjectB, both projects being within the same organization?","<p>Long story short, i have an api test framework and i want to import a method from it into the ui testing framework, both of which are in the same organization.</p>
<p>I'm using Intellij and have tried to add the api project as a dependency, I can then find the methods in the project but when compiling it throws:  <strong>Compilation failure: [ERROR] Class.java:[406,67] package_name does not exist</strong></p>
<p>I tried:</p>
<ul>
<li>invalidating caches and restarting</li>
<li>downloading dependencies</li>
<li>deleting project and pulling again, no luck.</li>
</ul>
<p>Please, keep in mind that the solution needs to work in CI when deploying the framework and running with the command &quot;mvn clean install&quot;, so making it work locally is only half a fix :).</p>
",https://stackoverflow.com/questions/74018752/how-do-i-import-with-java-intellij-a-method-from-projecta-to-projectb-both-pr,"['java', 'import', 'automation', 'shared-libraries']",18,False,0,0
how to select a custome dropdown option in Playwright UI test,"<p><strong>I am doing end to end UI testing and when I try to select an option for Harmony web UI component (&lt;ext-support_he-select&gt;), playwright is not able to recognize the custome tag and it error out saying not a select option.</strong></p>
<p>And I am not able to record dropdown select option with <strong>Headless Recorder</strong> as well, could you please let me know if anybody has come across this kind of issue.</p>
<p><strong>HTML Select Code :</strong>
{
&lt;ext-support_he-select id=&quot;workspace-dropdown&quot; class=&quot;basic-dropdown basic-workspace-dropdown below valid&quot; aria-labelledby=&quot;workspace-label&quot; role=&quot;combobox&quot; current-value=&quot;&quot; aria-controls=&quot;&quot; aria-disabled=&quot;false&quot; aria-expanded=&quot;false&quot; aria-haspopup=&quot;listbox&quot; tabindex=&quot;0&quot; position=&quot;below&quot; aria-activedescendant=&quot;option-14&quot;&gt;</p>
<pre><code>    &lt;ext-support_he-option selected=&quot;&quot; value=&quot;&quot; aria-selected=&quot;true&quot; class=&quot;selected&quot; role=&quot;option&quot; id=&quot;option-14&quot; aria-posinset=&quot;1&quot; aria-setsize=&quot;9&quot;&gt; Select a Workspace &lt;/ext-support_he-option&gt;
  
         
    &lt;ext-support_he-option value=&quot;accountPlans&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-15&quot; aria-posinset=&quot;2&quot; aria-setsize=&quot;9&quot;&gt; Account Plans &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;accounts&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-16&quot; aria-posinset=&quot;3&quot; aria-setsize=&quot;9&quot;&gt; Accounts &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;contacts&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-17&quot; aria-posinset=&quot;4&quot; aria-setsize=&quot;9&quot;&gt; Contacts &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;engagements&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-18&quot; aria-posinset=&quot;5&quot; aria-setsize=&quot;9&quot;&gt; Engagements &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;leads&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-19&quot; aria-posinset=&quot;6&quot; aria-setsize=&quot;9&quot;&gt; Leads &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;opportunities&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-20&quot; aria-posinset=&quot;7&quot; aria-setsize=&quot;9&quot;&gt; Opportunities &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;partners&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-21&quot; aria-posinset=&quot;8&quot; aria-setsize=&quot;9&quot;&gt; Partners &lt;/ext-support_he-option&gt;
   
    &lt;ext-support_he-option value=&quot;userProvisioning&quot; aria-selected=&quot;false&quot; role=&quot;option&quot; id=&quot;option-22&quot; aria-posinset=&quot;9&quot; aria-setsize=&quot;9&quot;&gt; User Provisioning &lt;/ext-support_he-option&gt;
  &lt;!--fast-eovm3s:5--&gt;
      &lt;/ext-support_he-select&gt; }
</code></pre>
<p>Please refer UI screenshot given below.
<a href=""https://i.stack.imgur.com/egdOF.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/egdOF.png"" alt=""enter image description here"" /></a></p>
",https://stackoverflow.com/questions/72452001/how-to-select-a-custome-dropdown-option-in-playwright-ui-test,"['html', 'testing', 'playwright', 'ui-testing', 'playwright-test']",2504,True,0,2
Selenium UI Automation Testing plugin in IntelliJ IDEA,"<p>Regarding <em>Selenium Support in IntelliJ IDEA</em>, I tend to use the methods recommended by jetbrains, which I found at</p>
<ul>
<li><a href=""https://blog.jetbrains.com/idea/2020/03/intellij-idea-2020-1-selenium-support/"" rel=""nofollow noreferrer"">https://blog.jetbrains.com/idea/2020/03/intellij-idea-2020-1-selenium-support/</a></li>
<li><a href=""https://www.jetbrains.com/help/idea/selenium.html"" rel=""nofollow noreferrer"">https://www.jetbrains.com/help/idea/selenium.html</a> (Last modified: 05 December 2022)</li>
</ul>
<p>They both recommend the <strong>Selenium UI Automation Testing</strong> plugin, yet I'm not able to find it myself:</p>
<p><a href=""https://i.stack.imgur.com/iL0rT.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/iL0rT.png"" alt=""enter image description here"" /></a></p>
<p>Digging deeper, I found<br />
<a href=""https://plugins.jetbrains.com/plugin/13691-selenium-ui-testing"" rel=""nofollow noreferrer"">https://plugins.jetbrains.com/plugin/13691-selenium-ui-testing</a></p>
<p>which says it is <em>&quot;Included In
Test Automation Kit&quot;</em></p>
<p>Yet, I'm unable to find the <em>&quot;Test Automation Kit&quot;</em> either.</p>
<p>Given that <a href=""https://www.jetbrains.com/help/idea/selenium.html"" rel=""nofollow noreferrer"">https://www.jetbrains.com/help/idea/selenium.html</a> was last modified at 05 December 2022, I'm thinking that I'm missing something very obvious. Please help.</p>
<p>How can I have Selenium Support in IntelliJ IDEA?<br />
How can I run Selenium scripts in IntelliJ IDEA?</p>
",https://stackoverflow.com/questions/74691305/selenium-ui-automation-testing-plugin-in-intellij-idea,"['java', 'selenium', 'intellij-idea', 'configuration']",212,False,0,0
Unable to take screenshots for iOS simulator version 12.4 using Appium,"<p>I am using Appium automation tool to automate UI testing for mobile app using C#.</p>
<p>Testing environment:</p>
<ul>
<li>XCode - 13.2.1</li>
<li>iOS - 12.4</li>
<li>Appium 1.22.3</li>
<li>Appium.WebDriver - 4.3.2</li>
</ul>
<p>When I run tests in iOS simulator 15.2, I can take screenshots using Appium without any errors. But in <strong>iOS simulator 12.4</strong>, I am getting error when taking screenshot.</p>
<p>Error is falling in the below line:</p>
<pre><code>Screenshot screenshot = driver.GetScreenshot();
</code></pre>
<p>Error I got in visual studio:</p>
<blockquote>
<p>OpenQA.Selenium.WebDriverException : The HTTP request to the remote
WebDriver server for URL
<a href=""http://127.0.0.1:4723/wd/hub/session/575ce7df-ffbb-4b2e-957c-e7eca7829b75/screenshot"" rel=""nofollow noreferrer"">http://127.0.0.1:4723/wd/hub/session/575ce7df-ffbb-4b2e-957c-e7eca7829b75/screenshot</a>
timed out after 60 seconds.
----&gt; System.Net.WebException : The operation has timed out.</p>
</blockquote>
<p>Appium Error Log:</p>
<blockquote>
<p>[debug] [W3C (575ce7df)] Calling AppiumDriver.getScreenshot() with
args: [&quot;575ce7df-ffbb-4b2e-957c-e7eca7829b75&quot;]
[debug] [XCUITest] Executing command 'getScreenshot'
[WD Proxy] Error: timeout of 240000ms exceeded</p>
</blockquote>
",https://stackoverflow.com/questions/72871447/unable-to-take-screenshots-for-ios-simulator-version-12-4-using-appium,"['c#', 'ios', 'appium', 'takesscreenshot']",93,False,0,0
ActionChains(driver).move_to_element(element).perform() on Jenkins,"<p>I am working on e2e UI testing with Selenium and using the Chrome driver.
My OS is macOS Big Sur.
I am testing the UI of the new upgraded website.
I can access the remote website needed to be tested on my laptop at any time.
I used the below method to affect the mouse cursor's hovering on a specific element in the UI.</p>
<pre><code>def mouse_hover(driver, locator):
    element = driver.find_element_by_xpath(locator)
    ActionChains(driver).move_to_element(element).perform()
</code></pre>
<p>but ActionChains (driver). move_to_element (element). perform () method is making an attribute error like below on Jenkins.
I made sure this method works on my local without any issues.</p>
<pre><code>        ActionChains(driver).move_to_element(element).perform()
/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/action_chains.py:273: in move_to_element
    self.w3c_actions.pointer_action.move_to(to_element)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;selenium.webdriver.common.actions.pointer_actions.PointerActions object at 0x7f04f2a7a610&gt;
element = &lt;selenium.webdriver.support.event_firing_webdriver.EventFiringWebElement object at 0x7f04f2ab66d0&gt;
x = None, y = None

    def move_to(self, element, x=None, y=None):
        if not isinstance(element, WebElement):
&gt;           raise AttributeError(&quot;move_to requires a WebElement&quot;)
E           AttributeError: move_to requires a WebElement

/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/actions/pointer_actions.py:42: AttributeError
</code></pre>
<p>I have tried to trigger the job on Jenkins many times but have always got the same result of this kind of error.</p>
<p>What alternative approach can affect the above method without any issue on Jenkins?
Anybody who has mastered using Jenkins can let me know.
Thank you.</p>
",https://stackoverflow.com/questions/72496324/actionchainsdriver-move-to-elementelement-perform-on-jenkins,"['selenium', 'jenkins', 'e2e-testing']",156,False,1,0
Espresso Testing Navigation with arguments Error,"<p>well I've been having problems when I want to test navigation components in UI testing with espresso. look at my test:</p>
<pre><code>    @Test
    fun detailsButton_clicked_navigateToDetailsFragment(){
    
    val scenario = launchFragmentInContainer&lt;ResistorCalcFragment&gt;(Bundle(), R.style.Theme_ResistorCalc)

    val navController = TestNavHostController(ApplicationProvider.getApplicationContext())

    scenario.onFragment{
        navController.setGraph(R.navigation.nav_graph)
        Navigation.setViewNavController(it.requireView(), navController)
    }

    onView(withId(R.id.color1_selection)).perform(click())
    onView(withText(&quot;Rojo&quot;))
        .inRoot(RootMatchers.isPlatformPopup())
        .perform(click())

    onView(withId(R.id.color2_selection)).perform(click())
    onView(withText(&quot;Rojo&quot;))
        .inRoot(RootMatchers.isPlatformPopup())
        .perform(click())

    onView(withId(R.id.multiplier_selection)).perform(click())
    onView(withText(&quot;Rojo&quot;))
        .inRoot(RootMatchers.isPlatformPopup())
        .perform(click())

    onView(withId(R.id.tolerance_selection)).perform(click())
    onView(withText(&quot;Rojo&quot;))
        .inRoot(RootMatchers.isPlatformPopup())
        .perform(click())

    onView(
        Matchers.allOf(
            isDescendantOfA(withId(R.id.erv_label)),
            withClassName(Matchers.endsWith(&quot;EditText&quot;))
        )
    ).perform(typeText(&quot;1234&quot;))

    onView(withId(R.id.details_button)).check(matches(isEnabled())).perform(
        closeSoftKeyboard(),
        scrollTo(),
        click()
    )
    assertThat(navController.currentDestination?.id).isEqualTo(R.id.resistorDetailsFragment)
}
</code></pre>
<p>Basically, the test fills a fragment with info, then checks if a button is enabled. Here is the point where my test crashes:</p>
<p>Error performing 'single click - At Coordinates: 531, 1778 and precision: 16, 16' on view 'view.getId() is &lt;2131296433/com.itc.resistorcalc:id/details_button&gt;'.</p>
<p>Navigation action/destination com.itc.resistorcalc:id/action_resistorCalcFragment_to_resistorDetailsFragment cannot be found from the current destination NavDestination(com.itc.resistorcalc:id/initialFragment)</p>
<p>Here is my nav graph:</p>
<pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;navigation xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:id=&quot;@+id/nav_graph&quot;
    app:startDestination=&quot;@id/initialFragment&quot;&gt;

    &lt;fragment
        android:id=&quot;@+id/resistorCalcFragment&quot;
        android:name=&quot;com.itc.resistorcalc.view.resistorcalc.ResistorCalcFragment&quot;
        android:label=&quot;@string/app_title&quot;
        tools:layout=&quot;@layout/fragment_resistor_calc&quot;&gt;
        &lt;action
            android:id=&quot;@+id/action_resistorCalcFragment_to_resistorDetailsFragment&quot;
            app:destination=&quot;@id/resistorDetailsFragment&quot;
            app:popUpTo=&quot;@id/resistorCalcFragment&quot;
            app:popUpToInclusive=&quot;true&quot; /&gt;

    &lt;/fragment&gt;
    &lt;fragment
        android:id=&quot;@+id/resistorDetailsFragment&quot;
        android:name=&quot;com.itc.resistorcalc.view.resistorcalc.ResistorDetailsFragment&quot;
        android:label=&quot;@string/app_title&quot;
        tools:layout=&quot;@layout/fragment_resistor_details&quot;&gt;
        &lt;argument
            android:name=&quot;ervValue&quot;
            app:argType=&quot;float&quot; /&gt;
        &lt;action
            android:id=&quot;@+id/action_resistorDetailsFragment_to_resistorCalcFragment&quot;
            app:destination=&quot;@id/resistorCalcFragment&quot;
            app:popUpTo=&quot;@id/resistorDetailsFragment&quot;
            app:popUpToInclusive=&quot;true&quot; /&gt;
    &lt;/fragment&gt;
    &lt;fragment
        android:id=&quot;@+id/initialFragment&quot;
        android:name=&quot;com.itc.resistorcalc.view.InitialFragment&quot;
        android:label=&quot;@string/app_title&quot;
        tools:layout=&quot;@layout/fragment_initial&quot;&gt;
        &lt;action
            android:id=&quot;@+id/action_initialFragment_to_resistorCalcFragment&quot;
            app:destination=&quot;@id/resistorCalcFragment&quot;
            app:popUpToInclusive=&quot;false&quot; /&gt;
        &lt;action
            android:id=&quot;@+id/action_initialFragment_to_fromValueResistorFragment&quot;
            app:destination=&quot;@id/fromValueResistorFragment&quot;
            app:popUpToInclusive=&quot;false&quot; /&gt;
    &lt;/fragment&gt;
    &lt;fragment
        android:id=&quot;@+id/fromValueResistorFragment&quot;
        android:name=&quot;com.itc.resistorcalc.view.fromvalueresistor.FromValueResistorFragment&quot;
        android:label=&quot;@string/app_title&quot;
        tools:layout=&quot;@layout/fragment_from_value_resistor&quot; /&gt;
&lt;/navigation&gt;
</code></pre>
<p>Here is the initialization of navigation components in main activity:</p>
<pre><code>class MainActivity : AppCompatActivity() {

    private lateinit var navController: NavController

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
        navController = navHostFragment.navController
        setupActionBarWithNavController(navController)
    }

    override fun onSupportNavigateUp(): Boolean {
        return navController.navigateUp() || super.onSupportNavigateUp()
    }
}
</code></pre>
<p>So I don't know why the current destination is set on initialFragment when I think it should be on resistorCalcFragment, or maybe is for the fact that I'm using safe args to send a float value from resistorCalcFragment to resistorDetailsFragment, any help appreciated!!</p>
",https://stackoverflow.com/questions/73196774/espresso-testing-navigation-with-arguments-error,"['android', 'android-espresso', 'android-testing', 'android-navigation', 'android-safe-args']",12,False,0,0
if else case in Android Espresso UI testing,"<p>In the application, I am writing Espresso UI test for login flow in the app. I wrote the test and it works fine, but I have one case where I have problem.</p>
<p>In this application, users sometimes get bonuses when opening app (usually they don't but this is let's say 1:100 scenario)
In these situations, the pop up appears on the screen and my test fails because my code tries to trigger the button that is not visible (it is under the pop up).</p>
<p>I would like to write if-else in a test where I can for example check the visibility of the pop up close button. So if this is visible click on it and if it's not, then continue normally.</p>
<p>But I didn't find any if-else syntax in UI testing. Can someone with more experience in UI espresso testing help me with some advice here? THanks</p>
",https://stackoverflow.com/questions/71666138/if-else-case-in-android-espresso-ui-testing,"['android', 'kotlin', 'android-espresso', 'ui-testing']",525,True,1,2
Is there a testing Framework for web-deployed Flutter applications?,"<p>I am wanting to automate and write tests for my Flutter <em><strong>deployed</strong></em> application.</p>
<p>I am able to test the client side of Flutter apps on mobile using Appium &amp; Codecept.js with no issues. (Built a testing project in VScode and used the built APK)</p>
<p>I have tried Playwright, Puppeteer, WebDriver, and Selenium with no luck on the deployed code for web. Piercing through <code>&lt;flt-glass-pane/&gt;</code> is possible but super messy and doesnt seem like a stable way to go about it. I am hoping to achieve this in my separate codebase that is responsible for UI testing.</p>
<p>I am wondering if anyone had some solid suggestions on automating a Flutter web app from the client side (UI, and clicks etc).</p>
<p>From the research I have done, I have not found a clear solution.  I am very interested in what you have used before that works or if you know the right direction I should head toward.</p>
",https://stackoverflow.com/questions/74059152/is-there-a-testing-framework-for-web-deployed-flutter-applications,"['flutter', 'automated-tests', 'webdriver', 'flutter-test', 'shadow-dom']",523,False,5,0
XCUIElementQuery in SwiftUI testing returns inconsistent count,"<p>I'm doing UI testing of a SwiftUI view, and I have the following code to fetch a List element to check the count of staticTexts in it:</p>
<pre><code>let pred = NSPredicate(format: &quot;identifier == 'detailViewTable'&quot;)
let detailViewTable = app.descendants(matching: .any).matching(pred).firstMatch
let arrOfTexts = detailViewTable.staticTexts
let ct = arrOfTexts.count
print(&quot;Count is: \(ct)&quot;) // This prints 0
print(&quot;Count is now: \(detailViewTable.staticTexts.count)&quot;) // Also prints 0
</code></pre>
<p>The count always prints as 0.</p>
<p>The SwiftUI view basically looks like this:</p>
<pre><code>List {
   Section(header: Text(&quot;Item list&quot;)) {
     HStack {
        Text(&quot;Number&quot;)
        Spacer()
        Text(rec.recNum)
     }
   }
// Lots more Sections/HStacks/Texts/etc here 
// ...
// ...
}
.accessibility(identifier: &quot;detailViewTable&quot;)
.listStyle(.grouped)
</code></pre>
<p>When I put a breakpoint as shown,</p>
<p><a href=""https://i.stack.imgur.com/g2qwh.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/g2qwh.png"" alt=""enter image description here"" /></a></p>
<p>and use <code>po</code> in the Debug Console, I get <strong>0</strong> for <code>ct</code>, but <strong>21</strong> if calling <code>count</code> directly:</p>
<pre><code>(lldb) po ct
0
(lldb) po detailViewTable.staticTexts.count
21
</code></pre>
<p>Pic here:</p>
<p><a href=""https://i.stack.imgur.com/uwDE6.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/uwDE6.png"" alt=""enter image description here"" /></a></p>
<p>Why is the var <code>ct</code> set to <strong>0</strong>, but calling the count directly gives me the correct number <strong>21</strong>?</p>
<p>It makes me wonder if the XCUIElementQuery takes a moment to run and returns the answer in some kind of implicit callback, and the data isn't ready at the moment the variable <code>ct</code> is set, but will return the correct answer in the debug console because it waits for the response. However, I don't see any discussion of a callback in the Apple documentation:</p>
<p><a href=""https://developer.apple.com/documentation/xctest/xcuielementquery"" rel=""nofollow noreferrer"">https://developer.apple.com/documentation/xctest/xcuielementquery</a></p>
",https://stackoverflow.com/questions/73424337/xcuielementquery-in-swiftui-testing-returns-inconsistent-count,"['unit-testing', 'testing', 'swiftui']",70,True,0,1
Can you create an Android testing app that runs atop of other specified android apps?,"<p>I'm trying to build an android application that essentially is able to scrape other apps to simulate a user for UI testing. Is this something that is possible? The technologies I'm using are Android Studio, Java, and UI Automator. I've done some research, but I haven't found anything that seems to directly confirm or deny that it's possible thus far. My strategy is thus:</p>
<ul>
<li>Start up application and grab all installed packages</li>
<li>Via a SearchView allow the tester to narrow their search and pick from the ListView</li>
<li>Then grab the packageName to launch the app via a new intent</li>
<li>Have user pick what tests to run (i.e. a view finder and log their ids into to LogCat to show that it is rendering correctly)</li>
</ul>
<p>I'm asking mainly to see if my strategy is either viable with either what technology I'm currently working with like UI Automator, my current strategy, or if it's viable at all due to Android OS' architecture</p>
",https://stackoverflow.com/questions/71386258/can-you-create-an-android-testing-app-that-runs-atop-of-other-specified-android,"['java', 'android', 'android-studio', 'automated-tests']",19,False,0,0
Swift Mocking Unit/ UI Testing,"<p>Basically I have a fairly large project built in MVP for which I need to incorporate UI and Unit testing wherever applicable.
The project has a large number of API calls, the client has requested that API calls be <strong>mocked</strong> within the App (Dummy data). So basically I need two targets in the App, one most likely the Production and the other just for testing where it does not contact the server and just mocks the requests and sends static pre defined Json data to the response handlers for the app to function with. The solution that I initially thought of was creating a global bool value and depending on the project target selected (Production (Bool value = False),Testing (Bool value = True)) so wherever a request is being made in the code, it would check this bool value and then choose to go with either the Testing Dummy Request (which returns static pre defined Json DATA to the response handler) or Live API request. But this kinda makes the code messy.
I'm fairly new to Unit/UI testing so Id appreciate any suggestions.
Thanks in advance :).</p>
",https://stackoverflow.com/questions/73111575/swift-mocking-unit-ui-testing,"['swift', 'xcode', 'unit-testing', 'mocking', 'xcode-ui-testing']",174,False,0,0
E2E/UI-test coverage (of &quot;critical features&quot;) in bigger java spring projects,"<p>we are currently revising our test automation processes and want to work on an interesting challenge: automatically get a test coverage for our E2E-tests (written in nodeJS-based tools like cypress or playwright)
similar to what can be done for unit test coverage</p>
<p><strong>our setup:</strong></p>
<ul>
<li>big enterprise applications mainly based on java spring - frontend: JSPs (SAP Commerce Cloud aka Hybris)
-- in newer projects, FE is not part of the java-app any more but a separate angular or react app
-- <strong>accessable as a web page</strong></li>
<li>gitlabCI as CI tool</li>
<li>sonarQube used currently for unit test coverage</li>
</ul>
<p><strong>what we want to achieve</strong></p>
<ul>
<li>a easy visible coverage of critical cases in different nodejs-based UI testing tools like cypress
-- similar to what sonarQube does for unit tests</li>
</ul>
<p>what do others do here? any experiences?
sorry if my question is not clear enough, I'm struggling to find a good way of doing it</p>
<p>so far just thought of investing in test management tools - manually writing down the critical test cases in JIRA (zephyr, xray, ...) and connecting those via jira-API with automated cypress-tests to get the test-result</p>
<p>but again.. a lot of manual work</p>
",https://stackoverflow.com/questions/74291478/e2e-ui-test-coverage-of-critical-features-in-bigger-java-spring-projects,"['e2e-testing', 'sap-commerce-cloud', 'gui-testing']",75,False,0,0
Automated API testing project - Where to deploy framework - CI/CD Pipeline,"<p>Automation Test Suite Architecture</p>
<p>Hi. The project I am working on has the following micro service architecture:-</p>
<p>1 - HTTPS web app Frontend UI Client (REACT JS)
2 - Backend Java API microservice (connected to a Postgres database)</p>
<p>I have created a Cypress UI frontend UI testing project within the REACT JS frontend web app project.</p>
<p>I have created a separate repo project for the automated API testing framework i.e. this is a standalone project (it is not part of the backend Java project repo). I have decided to use Cypress for API testing.</p>
<p>The CI/CD pipeline will deploy the frontend and backend projects to two separate AWS instances running Linux operating systems.</p>
<p>Questions:-</p>
<ol>
<li>My question is where is it best to deploy the automated API testing framework repo using the CI/CD pipeline? If it is deployed to the same server as the backend API then running the API tests from the same server would not be integration testing would it?</li>
<li>Is it best to deploy the automated API testing framework repo to its own separate AWS instance server?</li>
<li>Or is it best to deploy the automated API testing framework repo to either the frontend project AWS instance or the backend API micro service AWS instance?</li>
</ol>
<p>Thanks.</p>
",https://stackoverflow.com/questions/72786593/automated-api-testing-project-where-to-deploy-framework-ci-cd-pipeline,"['continuous-integration', 'microservices', 'cypress', 'web-api-testing']",47,False,0,0
Chrome binary not reachable when calling via selenium in aws lambda in quick successions,"<p>I am trying to deploy python-selenium, chrome, chromedriver onto aws lambda.
For that I am following this article.
<a href=""https://cloudbytes.dev/snippets/run-selenium-in-aws-lambda-for-ui-testing"" rel=""nofollow noreferrer"">https://cloudbytes.dev/snippets/run-selenium-in-aws-lambda-for-ui-testing</a></p>
<p>Now there is no error while building and when i call the lambda it works without any error.
But I noticed that whenever i call the lambda in quick successions, the first invocation works fine but all later invocations fail with the following message:</p>
<pre><code>Traceback (most recent call last):\n  File \&quot;/var/task/app.py\&quot;, line 141, in handler\n    response = scrape(**payload)\n  File \&quot;/var/task/app.py\&quot;, line 118, in scrape\n    WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.ID, \&quot;pane\&quot;)))\n  File \&quot;/var/lang/lib/python3.9/site-packages/selenium/webdriver/support/wait.py\&quot;, line 86, in until\n    value = method(self._driver)\n  File \&quot;/var/lang/lib/python3.9/site-packages/selenium/webdriver/support/expected_conditions.py\&quot;, line 125, in _predicate\n    return _element_if_visible(driver.find_element(*locator))\n  File \&quot;/var/lang/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py\&quot;, line 861, in find_element\n    return self.execute(Command.FIND_ELEMENT, {\&quot;using\&quot;: by, \&quot;value\&quot;: value})[\&quot;value\&quot;]\n  File \&quot;/var/lang/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py\&quot;, line 444, in execute\n    self.error_handler.check_response(response)\n  File \&quot;/var/lang/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py\&quot;, line 249, in check_response\n    raise exception_class(message, screen, stacktrace)\nselenium.common.exceptions.WebDriverException: Message: chrome not reachable\n  (Session info: headless chrome=103.0.5060.0)\nStacktrace:\n#0 0x563a3be05759 &lt;unknown&gt;\n#1 0x563a3bd9ecf3 &lt;unknown&gt;\n#2 0x563a3bb7dca7 &lt;unknown&gt;\n#3 0x563a3bb6eb94 &lt;unknown&gt;\n#4 0x563a3bb6f6ef &lt;unknown&gt;\n#5 0x563a3bb71612 &lt;unknown&gt;\n#6 0x563a3bb69a78 &lt;unknown&gt;\n#7 0x563a3bb7f2e3 &lt;unknown&gt;\n#8 0x563a3bbe41ce &lt;unknown&gt;\n#9 0x563a3bbd1ef3 &lt;unknown&gt;\n#10 0x563a3bba827b &lt;unknown&gt;\n#11 0x563a3bba9455 &lt;unknown&gt;\n#12 0x563a3bdcd870 &lt;unknown&gt;\n#13 0x563a3bddf8b0 &lt;unknown&gt;\n#14 0x563a3bddf5bc &lt;unknown&gt;\n#15 0x563a3bddfe32 &lt;unknown&gt;\n#16 0x563a3bdceb9b &lt;unknown&gt;\n#17 0x563a3bde00b6 &lt;unknown&gt;\n#18 0x563a3bdc04dd &lt;unknown&gt;\n#19 0x563a3bdf7888 &lt;unknown&gt;\n#20 0x563a3bdf7a12 &lt;unknown&gt;\n#21 0x563a3be11c2e &lt;unknown&gt;\n#22 0x7f5e9a8c144b &lt;unknown&gt;\n#23 0x7f5e993d858f &lt;unknown&gt;\n\n

</code></pre>
<p>namely <code>chrome not reachable</code>
This leads me to think that aws lambda is reusing the container when its called quickly and the first process is maybe not closing chrome/chromedriver properly? I am really not sure.
I found some similar questions in stackoverflow but none of their solutions work.
The general consensus i got from those other questions are the reason might be that there is a mismatch between the chrome and chromedriver version.</p>
<p>This is what i am using:
(Excerpt from the Dockerfile, full file can be seen on the link above)</p>
<p><code>ENV CHROMIUM_VERSION=1002910</code></p>
<p>And this where the binaries are being downloaded from (again can be seen in the link above).</p>
<pre><code>#!/bin/bash


echo &quot;Downloading Chromium...&quot;
curl &quot;https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/\
Linux_x64%2F$CHROMIUM_VERSION%2Fchrome-linux.zip?generation=1652397748160413&amp;alt=media&quot; &gt; /tmp/chromium.zip

unzip /tmp/chromium.zip -d /tmp/
mv /tmp/chrome-linux/ /opt/chrome

curl &quot;https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/\
Linux_x64%2F$CHROMIUM_VERSION%2Fchromedriver_linux64.zip?generation=1652397753719852&amp;alt=media&quot; &gt; /tmp/chromedriver_linux64.zip

unzip /tmp/chromedriver_linux64.zip -d /tmp/
mv /tmp/chromedriver_linux64/chromedriver /opt/chromedriver

</code></pre>
<p>It looks like I am using the compatible versions of chrome and chromedriver but nevertheless I tried to use some other versions of chrome (from this link <a href=""https://omahaproxy.appspot.com/"" rel=""nofollow noreferrer"">https://omahaproxy.appspot.com/</a>) but then wget call fails for either chrome or chromedriver.</p>
<p>Can someone let me know what I am doing wrong?</p>
<p>This is my py script that actually calls selenium:</p>
<pre><code>import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support import expected_conditions as ec
import json
import sys
import traceback
import urllib.request
import random
import string
import shutil


def get_random_string(size):
    return ''.join(random.choices(string.ascii_letters + string.digits, k=size))


CHROME_DRIVER_PATH = &quot;/opt/chromedriver&quot;
CHROMIUM_PATH = &quot;/opt/chrome/chrome&quot;
USER_DATA_DIR = f&quot;/tmp/chrome-user-data-{get_random_string(8)}&quot;
print(USER_DATA_DIR)


def get_exception_traceback(exception):
    if sys.version_info &gt;= (3, 10):
        tb = ''.join(traceback.format_exception(exception))
        return tb
    else:
        tb = ''.join(traceback.format_exception(etype=type(exception), value=exception, tb=exception.__traceback__))
        return tb


def get_ip_address():
    external_ip = urllib.request.urlopen('https://ident.me').read().decode('utf8')
    return external_ip


def get_location_id_from_api(api: str) -&gt; str:
    location_id = api.split(&quot;/&quot;)[-1]
    return location_id


def get_page_url_from_api(api: str) -&gt; str:
    page_url = f&quot;https://www.example.com/location/{get_location_id_from_api(api)}&quot;
    return page_url


def get_driver() -&gt; WebDriver:
    USER_AGENT = &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) \
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36&quot;

    chrome_options = webdriver.ChromeOptions()
    chrome_options.binary_location = CHROMIUM_PATH
    chrome_options.add_argument(&quot;--headless&quot;)
    chrome_options.add_argument(&quot;--no-sandbox&quot;)
    # chrome_options.add_argument(&quot;--disable-setuid-sandbox&quot;)
    chrome_options.add_argument(&quot;--disable-dev-shm-usage&quot;)
    chrome_options.add_argument(&quot;--disable-gpu&quot;)
    # chrome_options.add_argument(&quot;--disable-dev-tools&quot;)
    chrome_options.add_argument(&quot;--no-zygote&quot;)
    # chrome_options.add_argument(&quot;--single-process&quot;)
    chrome_options.add_argument(&quot;window-size=2560x1440&quot;)
    chrome_options.add_argument(f&quot;--user-data-dir={USER_DATA_DIR}&quot;)
    chrome_options.add_argument(&quot;--remote-debugging-port=9222&quot;)
    chrome_options.add_argument(f&quot;--user-agent={USER_AGENT}&quot;)
    # chrome_options.add_argument(&quot;--data-path=/tmp/chrome-user-data&quot;)
    # chrome_options.add_argument(&quot;--disk-cache-dir=/tmp/chrome-user-data&quot;)

    chrome_options.add_experimental_option(&quot;excludeSwitches&quot;, [&quot;enable-automation&quot;])
    chrome_options.add_experimental_option('useAutomationExtension', False)

    capabilities = DesiredCapabilities.CHROME
    capabilities[&quot;goog:loggingPrefs&quot;] = {&quot;performance&quot;: &quot;ALL&quot;}

    driver = webdriver.Chrome(CHROME_DRIVER_PATH, options=chrome_options, desired_capabilities=capabilities)

    return driver


def get_required_log(api, logs):
    for log in logs:
        log = json.loads(log[&quot;message&quot;])[&quot;message&quot;]
        if log[&quot;method&quot;] == &quot;Network.responseReceived&quot; and log['params'].get(&quot;response&quot;, {}).get(&quot;url&quot;, &quot;&quot;) == api and \
                log['params'].get(&quot;response&quot;, {}).get(&quot;mimeType&quot;, &quot;&quot;) == &quot;application/json&quot;:
            return log


def scrape(**kwargs):
    driver = None
    try:
        api = kwargs['url']
        url = get_page_url_from_api(api)
        location_id = get_location_id_from_api(api)
        print(&quot;url:&quot;, url)
        print(&quot;api:&quot;, api)
        print(&quot;location_id:&quot;, location_id)

        print(&quot;Getting chrome driver&quot;)
        driver = get_driver()
        print(&quot;Got chrome driver&quot;)

        print(&quot;Getting url in chrome&quot;)
        driver.get(url)
        print(&quot;Got url in chrome&quot;)
        WebDriverWait(driver, 10).until(ec.visibility_of_element_located((By.ID, &quot;pane&quot;)))
        print(&quot;Waiting for pane&quot;)

        logs = driver.get_log(&quot;performance&quot;)
        log = get_required_log(api, logs)
        response = driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': log[&quot;params&quot;][&quot;requestId&quot;]})
        body = json.loads(response['body'])
        if str(body.get(&quot;id&quot;, &quot;&quot;)) != location_id:
            raise Exception(&quot;Extracted wrong response: &quot;, body)
        print(json.dumps(body, indent=2))
        return {&quot;status&quot;: 200, &quot;text&quot;: response['body'], &quot;headers&quot;: {}}
    finally:
        if driver:
            driver.quit()
        shutil.rmtree(USER_DATA_DIR)


def handler(event, context):
    ip_address = None
    try:
        ip_address = get_ip_address()
        payload = json.loads(event[&quot;queryStringParameters&quot;][&quot;payload&quot;])
        response = scrape(**payload)
        return {&quot;success&quot;: True, &quot;ip_address&quot;: ip_address, &quot;data&quot;: response}
    except Exception as e:
        message = get_exception_traceback(e)
        print(message)
        return {&quot;success&quot;: False, &quot;ip_address&quot;: ip_address, &quot;error&quot;: message}

</code></pre>
",https://stackoverflow.com/questions/74448244/chrome-binary-not-reachable-when-calling-via-selenium-in-aws-lambda-in-quick-suc,"['python', 'selenium', 'selenium-chromedriver']",166,False,0,0
Testing socket.io-client with Jest (React) - How do I simulate an event from the server?,"<p>I built a simple React app that has a list component, together with another component that has a text input and a button.</p>
<p>When You add text in the input and click the button, that text is added to the list.</p>
<p>The app has a Node.js backend which communicates with the React client via Websocket (Socket.io). When the user clicks the button, what happens in practice is:</p>
<ol>
<li>The Socket.io client emits an event to the backend with the new item as the event payload</li>
<li>The backend saves it to a database</li>
<li>The backend then emits an event to all connected clients with the updated list.</li>
<li>The client side listens for this <code>'update-list'</code> event, and refreshes the list.</li>
</ol>
<p>I want to test this app - basic UI testing.
Specifically, I want to test the functionality of adding text to the input, then clicking the button and validating that the text is added to the list.</p>
<p>As you can gather from my description above, to be able to create a UI test for this functionality that can be run independent of a backend, I need to simulate an <code>'update-list'</code> event with a mocked payload in my Jest testing environment.</p>
<p>I know there are npm packages such as <a href=""https://www.npmjs.com/package/socket.io-mock"" rel=""nofollow noreferrer"">socket.io-mock</a> But I couldn't figure out how to use them to simulate a specific event with a specific mock payload.</p>
<p>I couldn't find how this can be done anywhere, would appreciate any help.</p>
",https://stackoverflow.com/questions/74339377/testing-socket-io-client-with-jest-react-how-do-i-simulate-an-event-from-the,"['reactjs', 'websocket', 'jestjs', 'socket.io', 'socket.io-client']",132,False,0,0
Selenium Timeout - Expected Condition returning False,"<p>I'm coding a bot in Python that plays tic-tac-toe. The game is a Web app written in React.js and is equipped with an AI of its own that utilizes minimax. The user (which the Python bot simulates) is always X, the AI is always O, and the user always moves first. The Python bot plays by randomly selecting unmarked squares (this is only to demonstrate automated UI testing).</p>
<p><strong>I was getting stuck inside a recursive function.</strong></p>
<p><em>for loop and recursive call:</em></p>
<pre><code>        for i in clickedSquares:
            if not winner:
                self.checkForWinner(load_browser, winner)          
            elif i == random_square:
                self.test_playTTT(load_browser)
            else:
                clickedSquares.append(random_square)
</code></pre>
<p>To fix this issue I added the <strong>if not winner</strong> condition where &quot;winner&quot; is a string. This does terminate the loop; however, I'm getting an error as soon as the checkForWinner() function is called because winnerOh is always false.</p>
<pre><code>        winnerOh = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultOh)))
        winnerEx = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultEx)))
        tiedGame = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultTie)))
</code></pre>
<p>I'm looking for an element on the UI that declares the winner: X or O or tie, which will only appear if the game is over.  So WebDriverWait().until() is timing out waiting for that element to appear, but it hasn't yet, because it's only the second move in the game.</p>
<p>I'm not sure how to fix this issue. If I remove the call to checkForWinner() the bot will get stuck in the recursive call to test_playTTT(). The browser will not close after the game is over, and the test will not end successfully.</p>
<p><strong>Is there another way to check the UI for the element I'm looking for that won't immediately return a False condition?  Is there a better way for me to write this for loop?</strong></p>
<p>Included below is the full Python method.</p>
<pre><code>class TestCase_PlayRandom():
    
    URL = &quot;http://localhost:3000&quot;
    
    @pytest.fixture
    def load_browser(self, browser):
        browser.get(self.URL)
        yield browser

    def test_playTTT(self, load_browser):

        squares = [Tags.square1,Tags.square2,Tags.square3,
                   Tags.square4,Tags.square5,Tags.square6,
                   Tags.square7,Tags.square8,Tags.square9]
            
        clickedSquares = []
        random_square = randint(0,8)
        time.sleep(5)
        winner = ''

        if not clickedSquares:
            element = load_browser.find_element(By.XPATH, squares[random_square])
            element.click()
            clickedSquares.append(random_square)

        for i in range(0,9):
            if squares[i] == Tags.ohSquare:
                clickedSquares.append(i)
            
        for i in clickedSquares:
            if not winner:
                self.checkForWinner(load_browser, winner)          
            elif i == random_square:
                self.test_playTTT(load_browser)
            else:
                clickedSquares.append(random_square)
            
        element = load_browser.find_element(By.XPATH, squares[random_square])
        element.click()

    def checkForWinner(self, load_browser, winner):

        winnerOh = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultOh)))
        winnerEx = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultEx)))
        tiedGame = WebDriverWait(load_browser, 10).until(EC.presence_of_element_located((By.XPATH, Tags.resultTie)))
    
        if winnerOh:
            winner = 'O'
            LOGGER.info('Winner O')
            return winner
        elif winnerEx:
            winner = 'X'
            LOGGER.info('Winner X')
            return winner
        elif tiedGame:
            winner = 'None'
            LOGGER.info('Tie')
            return winner
</code></pre>
",https://stackoverflow.com/questions/74075172/selenium-timeout-expected-condition-returning-false,"['python', 'selenium-webdriver', 'pytest', 'gui-testing']",67,False,1,1
How to access webview code in VS code’s DOM for UI testing,"<p>I am trying to automate UI testing of the extension for VS Code that has certain actions brought out into the SideBarView section as webview, self-written HTML that I want to access via Selenium webdriver (I use vscode-extension-tester package that provides almost every API necessary and is fantastically helpful, btw).</p>
<p>There's no problem accessing html from VS Code's DevTools, for example a button is exposed as &quot;vscode-button&quot; tag inside a webview's &quot;iframe&quot; tag, so I assume finding it by xpath might work:</p>
<pre><code>let webElement = await driver.findElement(By.xpath('//vscode-button[contains(@onclick, &quot;loadMarkers&quot;)]'));
</code></pre>
<p>But when I run Extension host for testing, its DOM does not contain webview code, so findElement() returns &quot;undefined&quot;. If I understand correctly, it only has a reference to the webview tag with the pointer to vscode extension that handles webview content, so I have to switch to that webview somehow. Page source shows only &quot;div&quot; with webview link inside an &quot;iframe&quot;:</p>
<pre><code>&lt;div id=&quot;webview-&lt;id&gt;&quot;...
  &lt;iframe name=&quot;&lt;id&gt;&quot; class=&quot;webview ready&quot;... src=&quot;vscode-webview...;extensionId=&lt;id&gt;...;purpose=webviewView&quot;...&gt;&lt;/iframe&gt;
</code></pre>
<p>Haven't found anything in VS Code API document, currently reading about Electron webview API to understand if there are any other suggestions.</p>
<p>Vscode-extension-tester API provides switching to webview context from a different object, however. So I wondered if there is a generic way to do so.
<a href=""https://github.com/redhat-developer/vscode-extension-tester/wiki/WebView"" rel=""nofollow noreferrer"">https://github.com/redhat-developer/vscode-extension-tester/wiki/WebView</a></p>
<p>p.s. I began working on automated testing just a while ago, so I may miss something obvious (that would be great to have a solution at hand), but it looks like there are no easy ways to solve my problem at the moment. Would appreciate any help you can provide.</p>
",https://stackoverflow.com/questions/73202635/how-to-access-webview-code-in-vs-code-s-dom-for-ui-testing,"['selenium-webdriver', 'visual-studio-code', 'webview']",171,False,1,0
Using WebApplicationFactory to do E2E testing with .Net 6 (minimal api),"<p>Im trying to get E2E/UI testing (selenium, playwright) to work with my unit testing framework.</p>
<p>The basic idea it to use MSTest and the WebApplicationFactory to spin up a &quot;real server&quot; from within my unit tests. The reason for doing this would be to simply avoid having to deploy/release my application for testing (I guess this could be done by using containers etc, sadly.. Im not allowed to use containers). Im also thinking that doing it this wasy would be a &quot;neat&quot; way of mocking any code that calls external services, and be able to create multiple tests with different scenarios for those external calls.</p>
<p>I have searched the web for a way of doing this, but all I can find are posts about how to do this in previous .Net versions (2.1-5), but since .Net 6 the &quot;startup ceremonial&quot; code has changed and the standard way is now to use the minimal API.</p>
<p>Here is a blog post from Scott.H where he is basically doing exactly what Im planing to do, but with .Net 2.1: <a href=""https://www.hanselman.com/blog/real-browser-integration-testing-with-selenium-standalone-chrome-and-aspnet-core-21"" rel=""nofollow noreferrer"">https://www.hanselman.com/blog/real-browser-integration-testing-with-selenium-standalone-chrome-and-aspnet-core-21</a></p>
<p>What I have done so far is creating a custom class that inherits from WebApplicationFactory.</p>
<p>basically:</p>
<pre><code>class MyAppFactory : WebApplicationFactory&lt;Program&gt; {

}
</code></pre>
<p>And I can use that perfectly fine for integration testing. However.. the server thats initialized when using that class does not accept http-calls, so I cant reach that using a web browser, and neither can selenium.</p>
<p>I tried to follow Scotts blog post. But for some reason the:</p>
<pre><code>protected override TestServer CreateServer(IWebHostBuilder builder)
</code></pre>
<p>Is never called.. (not sure if that has with minimal APIs and .Net 6 to do).</p>
<p>Has anyone managed to use the WebApplicationFactory and .Net 6 Minimal API to spin up an &quot;actual server&quot; in memory that accepts http-calls?</p>
",https://stackoverflow.com/questions/71541576/using-webapplicationfactory-to-do-e2e-testing-with-net-6-minimal-api,"['testing', '.net-6.0']",1645,True,2,2
How to prevent &#39;Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost&#39; exception,"<p>I have a .NET 6.0 solution I use for automated UI testing of a web application. This solution consists of a number of projects, one of which contains all the tests, another being the logging implementation for the tests, and the others for other miscellaneous dependencies the framework has.</p>
<p>The project containing the tests uses NUnit as the test framework - it has the NuGet packages NUnit (3.13.3) and NUnit3TestAdapter (4.2.1). The logging project also includes the NUnit package because it uses the NUnit.Framework.TestContext to write out logs to the context of each test running.</p>
<p>I am using VS 2022 for the development of this solution. When I perform a build of the solution it will tell me the build succeeded (briefly flashing up in the bottom right) before immediately saying &quot;Unexpected error detected. Check the Tests Output Pane for details.&quot;. If I check that I can see:</p>
<pre><code>Test project MyNamespace.Logging does not reference any .NET NuGet adapter. Test discovery or execution might not work for this project.
It's recommended to reference NuGet test adapters in each test project in the solution.
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery complete
========== Test discovery aborted: 60 Tests found in 1 sec ==========
</code></pre>
<p>So it's complaining that there is no test adaptor for my logging project. Of course I do not want or need an adaptor for this project as it legitimately contains no tests. Just to try and make some progress I installed the same NUnit adaptor as my test project uses. The error in the Test Output Pane then reduces to:</p>
<pre><code>========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
NUnit Adapter 4.2.0.0: Test discovery starting
NUnit Adapter 4.2.0.0: Test discovery complete
========== Test discovery aborted: 60 Tests found in 1.1 sec ==========
</code></pre>
<p>So installing the package clears the first part of it (but of course I don't really want to install it). I then had a read of the NUnit docs and found the <code>NonTestAssembly</code> attribute which seemed like it might be what I needed. I created an AssemblyInfo.cs file and added it in to the root of my logging project and then added the line <code>[assembly: NUnit.Framework.NonTestAssembly]</code> within it. Rebuilt the solution but the error remains as above. Does anyone know what I can do to get VS to be happy with this? Its frustrating as it shows the conical flask icon over my logging project which isn't ideal and then also makes it harder to see the 'Build succeeded' message as it's quickly overridden with the error.</p>
<p>Am I wrong to use the NUnit package as I am doing?</p>
",https://stackoverflow.com/questions/73731239/how-to-prevent-microsoft-visualstudio-testplatform-objectmodel-testplatformexce,"['c#', '.net', 'visual-studio', 'nunit']",2415,True,4,1
