What is the "click()" element in this scenario?

user3595231

There is a switch-on/switch-off element on a Web Page. And underneath, here is the source code defined:

<div class = "button">
  <label class = "switch">
    <input id="sim-switch" class = "hidden" type="checkbox">
       <div class = "slider clearfix">
           ::before
           <div class="on-text pull-left">ON</div>
           <div class="off-text pull-left">OFF<div>
           <div class="inner-slider"></div>
           ::after
       </div>
  </label>
</div>

And if was to put this step into selenium automation, I am not sure which part is the "click()" area to make this switch happen. Any ideas?

iamsankalp89

You can use checkbox for operation, first locate element and use the isChecked() method with if else conditions for operations:

 WebElement ele= driver.findElement(By.id("sim-switch"));
 if(ele.isSelected()==true)
 {
     System.out.println("it is clicked");
     //append your operations
 }
 else
 {
     ele.click();
     System.out.println("it is now clicked");
     //append your operations
 }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to click a parent element using the child element for the following scenario

From Dev

What are the best practices for programming the behaviors of the scenario elements in a point and click game?

From Dev

What's the issue in accessing associative array element in smarty in following scenario?

From Dev

What is the $scenario variable in Codeception?

From Dev

Click through an element, affecting what's behind it

From Dev

What pattern to use for the following scenario?

From Dev

What will happen in the following mulththreaded scenario?

From Dev

What are the steps to convert a Scenario to BPMN?

From Dev

What is the flow for svn update in this scenario?

From Dev

what is the Algorithm used to identify the scenario

From Dev

What pattern to use for the following scenario?

From Dev

What is the best database structure In this scenario?

From Dev

What is MarkSelection in Eclipse, it will be used in what scenario?

From Dev

Javascript: What is the fastest way to click an element a million times

From Dev

What makes HTML element animate on click event without JavaScript?

From Dev

What is the selector should be used when applying .click() to an li element?

From Dev

What makes HTML element animate on click event without JavaScript?

From Dev

Closing element on click outside - What am I doing wrong here?

From Dev

How to prevent an a element's click event what bind by angular?

From Dev

How to get parent element height in my scenario?

From Dev

What exception to throw - "Wrong Scenario" (Java)

From Dev

What the scenario call fs.close is necessary

From Dev

What is the worst case scenario for an unordered_map?

From Dev

TFS - What is the best branching strategy for this scenario?

From Dev

In what scenario 'this' pointer is passed to the class methods?

From Dev

What is the best way to implement promise in the given scenario?

From Dev

What is given priority in below scenario @Bean or @Component?

From Dev

In what scenario IIS respond with 304 response code

From Dev

What is best Ruby Class design / pattern for this scenario?

Related Related

  1. 1

    How to click a parent element using the child element for the following scenario

  2. 2

    What are the best practices for programming the behaviors of the scenario elements in a point and click game?

  3. 3

    What's the issue in accessing associative array element in smarty in following scenario?

  4. 4

    What is the $scenario variable in Codeception?

  5. 5

    Click through an element, affecting what's behind it

  6. 6

    What pattern to use for the following scenario?

  7. 7

    What will happen in the following mulththreaded scenario?

  8. 8

    What are the steps to convert a Scenario to BPMN?

  9. 9

    What is the flow for svn update in this scenario?

  10. 10

    what is the Algorithm used to identify the scenario

  11. 11

    What pattern to use for the following scenario?

  12. 12

    What is the best database structure In this scenario?

  13. 13

    What is MarkSelection in Eclipse, it will be used in what scenario?

  14. 14

    Javascript: What is the fastest way to click an element a million times

  15. 15

    What makes HTML element animate on click event without JavaScript?

  16. 16

    What is the selector should be used when applying .click() to an li element?

  17. 17

    What makes HTML element animate on click event without JavaScript?

  18. 18

    Closing element on click outside - What am I doing wrong here?

  19. 19

    How to prevent an a element's click event what bind by angular?

  20. 20

    How to get parent element height in my scenario?

  21. 21

    What exception to throw - "Wrong Scenario" (Java)

  22. 22

    What the scenario call fs.close is necessary

  23. 23

    What is the worst case scenario for an unordered_map?

  24. 24

    TFS - What is the best branching strategy for this scenario?

  25. 25

    In what scenario 'this' pointer is passed to the class methods?

  26. 26

    What is the best way to implement promise in the given scenario?

  27. 27

    What is given priority in below scenario @Bean or @Component?

  28. 28

    In what scenario IIS respond with 304 response code

  29. 29

    What is best Ruby Class design / pattern for this scenario?

HotTag

Archive