Forum Discussion

altus_nel's avatar
altus_nel
Contributor
11 years ago

Enabling WiFi on Android devices

Hi there,



TC very nicely allows you to either disable / enable to the the WiFi connection of the device. 



Now, disbabling the connections (Mobile.Device().Connections.WiFiEnabled = false;) disables the wift and all is well.



The problem i'm facing is that when the WiFi is enabled again (WiFiEnabled = true;) then i get a message: "An attempt to change the state of the device's WiFi adapter failed. The WiFi adapter is still off.



The problem with this is that I am not experiencing any error. The WiFi is turned on successfully on the device.



Even when putting the method in a try / catch block, the "exception" is not caught and the scripts exits (since stop on error is enabled).



This has been observed on a Samsung Galaxy S3 and a Note 2



Is there some sort of workaround for this? Or am i doing it wrong? :)



Thanks!
  • Hi Altus,

     


    Our QA team didn't face this error when testing the product. 


     


    Could you please follow the steps below to help them better understand what is going on on your device?


     


    1. Run Command Prompt on your computer.


     


    2. Navigate to the "<Android SDK>\Platform-tools\" folder. To do this, type:


    cd <your_drive_letter>:\<path_to_the_Android SDK>\Platform-tools\


     


    3. Execute the following command with Android Debugging Bridge:


    adb shell logcat -c


     


    4. Launch your test in TestComplete and reproduce the issue.


     


    5. Execute the following command with Android Debugging Bridge to generate the report:


    adb shell logcat -d > dump.txt


     


    The "dump.txt" file will be created on your machine where the "adb.exe" executable file is located.


     


    6. Send the generated file to our Support team.


     


    Thanks in advance.


     

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    As a workaround, you should be able to block posting of this particular error via the OnLogError event handler.

    Doesn't it work?
  • Hi Alexei



    Yeah, i can block the message from being posted to the log. If however (for some reason), the WiFi is actually not enabled, then this would negatively affect my test (since i'm now blocking the exception from being logged). 



    A bit of a catch 22 if you ask me :)



    I can interogate the state of the WiFi perhaps after the "error" is generated and do further processing. This does seem like extra work that should be handled by the application though.



    In any event, thanks for the reply!



    Regards,

    Altus
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Altus,

     


    Our QA team didn't face this error when testing the product. 


     


    Could you please follow the steps below to help them better understand what is going on on your device?


     


    1. Run Command Prompt on your computer.


     


    2. Navigate to the "<Android SDK>\Platform-tools\" folder. To do this, type:


    cd <your_drive_letter>:\<path_to_the_Android SDK>\Platform-tools\


     


    3. Execute the following command with Android Debugging Bridge:


    adb shell logcat -c


     


    4. Launch your test in TestComplete and reproduce the issue.


     


    5. Execute the following command with Android Debugging Bridge to generate the report:


    adb shell logcat -d > dump.txt


     


    The "dump.txt" file will be created on your machine where the "adb.exe" executable file is located.


     


    6. Send the generated file to our Support team.


     


    Thanks in advance.