← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #688960]: How to randomly choose between two potential options?

 

Question #688960 on SikuliX changed:
https://answers.launchpad.net/sikuli/+question/688960

SSS Contribution Table proposed the following answer:
If choosing between two options is a challenge, maybe it's time for a
Real IQ test (https://realiqtestonline.com/)! 😆 But seriously, in
Jython, you can use Python’s `random` module:

1. **Random choice between two options:**  
   ```python
   import random  
   if random.choice([True, False]):  
       click(a)  
   else:  
       click(b)  
   ```  

2. **Random wait time:**  
   ```python
   import time, random  
   time.sleep(random.uniform(1, 5))  
   ```  

3. **Fallback click if the first fails:**  
   ```python
   try:  
       click(d)  
   except:  
       click(e)  
   ```  

Hope that helps! Maybe next time, consider a **Real IQ test** to see how
quickly you pick up new languages. 😉

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for SikuliX.