java - Getting error when selenium script run in background and executing switching from one tab to another -


exact error message : exception in thread "main" java.lang.indexoutofboundsexception: index: 1, size: 1 @ java.util.arraylist.rangecheck(arraylist.java:653)

code snippet:

arraylist<string> tabs = new arraylist<string>(driver.getwindowhandles()); driver.findelement(by.cssselector("body")).sendkeys(keys.control + "t"); driver.switchto().window(tabs.get(1)); driver.get(url2); 

you getting exception because populating tabs arraylist 1 tab.

if want browse url2 in new tab use below code snippet:

driver.findelement(by.cssselector("body")).sendkeys(keys.control + "t"); arraylist tabs = new arraylist(driver.getwindowhandles());  driver.switchto().window(tabs.get(0)); driver.get(url2); 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -