I have been utilizing Selenium Webdriver to conduct testing on a web application that is currently undergoing development. Despite having developed multiple tests already, I am facing challenges in attempting to open new tabs within the window controlled by Selenium. After exploring numerous solutions, most of which are geared towards Java or Python (and not applicable to my Javascript requirements), I have yet to achieve success.
Here are some key details:
Selenium Webdriver: v.3.1.0 OS: Xubuntu 16.04 Browsers: Chrome 55.0.2883.87 and Firefox 50.1.0
Various solutions I have tried include:
Utilizing action sequences, which were ineffective in both Chrome and Firefox, with Firefox generating an error:
driver.actions().keyDown(Key.CONTROL).sendKeys('n').keyUp(Key.CONTROL).perform();
Experimenting with Key.chord(), resulting in silent execution but producing unexpected charCodes in Firefox:
driver.findElement(By.css("body")).sendKeys(Key.chord(Key.CONTROL, 't'));
Restricting usage to Key.CONTROL alone, leading to successful key inputs but again displaying unusual charCodes in Firefox:
driver.findElement(By.css("body")).sendKeys(Key.CONTROL + "t");
My current approach involves directing the driver to a webpage equipped with javascript keypress detection, verifying if the keys were triggered after inputting 'aaa':
driver.get("http://unixpapa.com/js/testkey.html");
driver.findElement(By.css("body")).sendKeys("aaa");
driver.findElement(By.css("body")).sendKeys(Key.CONTROL + "t");
This action results in the following output displayed on the page's detection area:
keydown keyCode=17 which=17 charCode=0
keydown keyCode=84 (T) which=84 (T) charCode=0
keypress keyCode=116 (t) which=116 (t) charCode=116 (t)
keyup keyCode=84 (T) which=84 (T) charCode=0
keyup keyCode=17 which=17 charCode=0
Although it indicates keystrokes have been detected, no response is elicited and no additional tabs are created. Absence of errors, warnings, or notifications has left me uncertain whether this issue stems from a bug, a configuration misstep, or any other potential factor. Any insights or suggestions would be greatly appreciated for resolving this dilemma.