DHCPv6 toggle does not impact IPv4 settings

    Changes:
        Verify Enable Or Disable DHCPv6 Does Not Impact IPv4 Settings

    Tested:
        Ran and Tested on BMC Environment

Change-Id: I42366dd6ae671a903a39a9dde9c989717a751975
Signed-off-by: Feroz M A <m.a.feroz@ibm.com>
diff --git a/gui/gui_test/settings_menu/test_network_sub_menu.robot b/gui/gui_test/settings_menu/test_network_sub_menu.robot
index f51bfae..c450fee 100644
--- a/gui/gui_test/settings_menu/test_network_sub_menu.robot
+++ b/gui/gui_test/settings_menu/test_network_sub_menu.robot
@@ -43,6 +43,8 @@
 ${xpath_dns_switch_button}               //*[@id="useDnsSwitch"]/following-sibling::label
 ${xpath_domainname_switch_button}        //*[@id="useDomainNameSwitch"]/following-sibling::label
 ${xpath_success_popup}                   //*[contains(text(),'Success')]/following-sibling::button
+${ipv4_elements}                         //h2[contains(., "IPv4")]/following::table[1]/tbody/tr/td[1]
+${ipv6_elements}                         //h2[contains(., "IPv6")]/following::table[1]/tbody/tr/td[1]
 ${xpath_delete_ipv4_addres}              //*[text()='${test_ipv4_addr_2}']/following::td[4]
 ...                                      //*[@title="Delete IPv4 address"]
 ${xpath_delete_ipv6_addres}              //*[text()='${test_ipv6_addr_2}']/following::td[3]
@@ -55,15 +57,15 @@
 ...                                      //*[@title="Delete IPv6 static default gateway address"]
 ${xpath_edit_ipv6_def_gateway_addr}      //*[text()='${test_ipv6_addr}']/following::td[1]
 ...                                      //*[@title="Edit IPv6 static default gateway address"]
-${xpath_edit_ipv6_def_gateway_addr_1}      //*[text()='${test_ipv6_addr_1}']/following::td[1]
+${xpath_edit_ipv6_def_gateway_addr_1}    //*[text()='${test_ipv6_addr_1}']/following::td[1]
 ...                                      //*[@title="Edit IPv6 static default gateway address"]
 ${xpath_ipv6_addr_edit_button}           //*[text()='{}']/following::td[3]
 ...                                      //*[@title="Edit static IPv6 address"]
 ${xpath_ipv6_addr_delete_button}         //*[text()='{}']/following::td[3]
 ...                                      //*[@title="Delete IPv6 address"]
 ${xpath_delete_button}                   //*[text()="Delete"]
-${xpath_eth1_interface}                  //*[text()="eth1"]
 ${xpath_eth0_interface}                  //*[text()="eth0"]
+${xpath_eth1_interface}                  //*[text()="eth1"]
 ${xpath_linklocalv6}                     //*[text()="LinkLocal"]
 ${xpath_eth0_ipv6_autoconfig_button}     (//*[@id="ipv6AutoConfigSwitch"]/following-sibling::label)[1]
 ${xpath_eth1_ipv6_autoconfig_button}     (//*[@id="ipv6AutoConfigSwitch"]/following-sibling::label)[2]
@@ -549,22 +551,17 @@
     Modify Default IPv6 Gateway And Verify  ${test_ipv6_addr}  ${test_ipv6_addr_1}
 
 
-Verify Edit And Delete Button Is Disabled For Dynamic IPv6 Addresses
-    [Documentation]  Verify edit and delete button is disabled in
-    ...    link local, SLAAC and DHCPv6 configuration.
-    [Tags]  Verify_Edit_And_Delete_Button_Is_Disabled_For_Dynamic_IPv6_Addresses
-    [Setup]  Run Keywords
-    ...  Set And Verify DHCPv6 States  Enabled  Enabled
-    ...  AND  Set SLAAC Property On Eth0 And Eth1  Enabled
-    [Template]  Verify Edit And Delete Button Is Disabled
+Verify Enable Or Disable DHCPv6 Does Not Impact IPv4 Settings
+    [Documentation]  Verify enable or disable DHCPv6 and it does not have impact on IPv4 settings
+    ...  Note: Enable testcase need DHCPv6 setup.
+    [Tags]  Verify_Enable_Or_Disable_DHCPv6_Does_Not_Impact_IPv4_Settings
+    [Template]  Enable Or Disable DHCPv6 And Verify Impact On IPv4 Settings
 
-    # Address type      Channel number.
-    DHCPv6              ${1}
-    SLAAC               ${1}
-    LinkLocal           ${1}
-    DHCPv6              ${2}
-    SLAAC               ${2}
-    LinkLocal           ${2}
+    # ip_version   channel_number  desired_status
+    ipv4           1               Disabled
+    ipv4           1               Enabled
+    ipv4           2               Disabled
+    ipv4           2               Enabled
 
 
 Configure Link Local IPv6 Address Via GUI And Verify
@@ -1045,12 +1042,18 @@
 
 
 Verify DHCPv6 Address On Enable
-    [Documentation]  Verify DHCPv6 on enable, make sure the system has DHCP setup.
+    [Documentation]  Verify DHCPv6 on enable, if missing log warning and continue.
 
-    @{ipv6_address_origin_list}  ${ipv6_dhcpv6_addr}=
-    ...    Get Address Origin List And Address For Type  DHCPv6
-    Wait Until Page Contains  ${ipv6_dhcpv6_addr}
-    Wait Until Page Contains  DHCPv6
+    TRY
+      @{ipv6_address_origin_list}  ${ipv6_dhcpv6_addr}=
+      ...  Get Address Origin List And Address For Type  DHCPv6
+    EXCEPT
+      Log  DHCPv6 setup is missing!  WARN
+      RETURN
+    ELSE
+      Wait Until Page Contains  ${ipv6_dhcpv6_addr}  timeout=30s
+      Wait Until Page Contains  DHCPv6  timeout=30s
+    END
 
 
 Set And Verify DHCPv6 States
@@ -1109,32 +1112,60 @@
     Wait Until Page Contains  ${ipv6_type}
 
 
-Verify Edit And Delete Button Is Disabled
-    [Documentation]  Verify edit and delete button is disabled in configuration.
-    [Arguments]  ${ipv6_type}  ${channel_number}=${None}
+Collect All IP Addresses On Both Interfaces
+    [Documentation]  Collecting all the IP addresses on both interfaces.
+    [Arguments]  ${ip_version}  ${channel_number}
 
     # Description of argument(s):
-    # ipv6_type       Type of IPv6 address(e.g:slaac/dhcpv6/linklocal).
+    # ip_version      Either 'ipv4' or 'ipv6'.
     # channel_number  Ethernet channel number, 1(eth0) or 2(eth1).
 
-    @{ipv6_address_origin_list}  ${ipv6_addr}=
-    ...    Get Address Origin List And Address For Type  ${ipv6_type}  ${channel_number}
-
-    # Verify edit button is disabled.
-    ${edit_addr}=  Replace String
-    ...  ${xpath_ipv6_addr_edit_button}  {}  ${ipv6_addr}
-
-    IF    '${channel_number}' == '1'
-        Click Element  ${xpath_eth0_interface}
-    ELSE IF    '${channel_number}' == '2'
-        Click Element  ${xpath_eth1_interface}
+    IF  '${channel_number}' == '1'
+      Wait Until Element Is Enabled  ${xpath_eth1_interface}  timeout=60s
+      Click Element  ${xpath_eth0_interface}
+    ELSE
+      Wait Until Element Is Enabled  ${xpath_eth1_interface}  timeout=60s
+      Click Element  ${xpath_eth1_interface}
     END
 
-    ${edit_button_status}=  Get Element Attribute  ${edit_addr}  disabled
-    Should Be Equal  ${edit_button_status}  true
+    IF  '${ip_version}' == 'ipv4'
+      Wait Until Element Is Enabled  ${xpath_add_static_ipv4_address_button}  timeout=30s
+      ${ip_elements}=  Get WebElements  ${ipv4_elements}
+    ELSE IF  '${ip_version}' == 'ipv6'
+      Wait Until Element Is Enabled  ${xpath_add_static_ipv6_address_button}  timeout=30s
+      ${ip_elements}=  Get WebElements  ${ipv6_elements}
+    ELSE
+      Fail  Invalid IP version provided. Use 'ipv4' or 'ipv6'.
+    END
 
-    # Verify delete button is disabled.
-    ${delete_addr}=  Replace String
-    ...  ${xpath_ipv6_addr_delete_button}  {}  ${ipv6_addr}
-    ${delete_button_status}=  Get Element Attribute  ${delete_addr}  disabled
-    Should Be Equal  ${delete_button_status}  true
\ No newline at end of file
+    ${ip_list}=  Create List
+    FOR  ${elem}  IN  @{ip_elements}
+      ${ip}=  Get Text  ${elem}
+      ${ip}=  Strip String  ${ip}
+      IF  '${ip}' != '' and '${ip}' != 'No items available'
+        Append To List  ${ip_list}  ${ip}
+      END
+    END
+    RETURN  ${ip_list}
+
+
+Enable Or Disable DHCPv6 And Verify Impact On IPv4 Settings
+    [Documentation]  Enable or Disable DHCPv6 and it does not have impact on IPv4 settings.
+    [Arguments]  ${ip_version}  ${channel_number}  ${desired_dhcpv6_state}
+
+    # Description of argument(s):
+    # ip_version            Either 'ipv4' or 'ipv6'.
+    # channel_number        Ethernet channel number, 1(eth0) or 2(eth1).
+    # desired_dhcpv6_state  DHCPv6 Toggle state (Enabled or Disabled).
+
+    # Capture IPv4 addresses before disabling DHCPv6.
+    ${ipv4_before}=  Collect All IP Addresses On Both Interfaces  ${ip_version}  ${channel_number}
+
+    Toggle DHCPv6 State And Verify  ${desired_dhcpv6_state}  ${channel_number}
+    Sleep  ${NETWORK_TIMEOUT}
+    Reload Page
+    Wait Until Element Is Enabled  ${xpath_static_ipv4}  timeout=30s
+
+    # Capture IPv4 addresses after disabling DHCPv6.
+    ${ipv4_after}=  Collect All IP Addresses On Both Interfaces  ${ip_version}  ${channel_number}
+    Lists Should Be Equal  ${ipv4_before}  ${ipv4_after}  ignore_order=True