Running Java/Selenium 2.3 (and 4) using Firefox Driver on centos
Trying to test against a site that has form with a text type, with an onchange. Tried to insert the text using the sendkeys, and then changing focus by doing a select/click on another term in the form. Tried to do a fireevent as well. (Doesn't appear to be supported in the 2.3 sel)
Searched the net as well with no luck.
Basically, trying to get a solution to how to do an insert into a textbox for selenium/firefox driver, so the inserted text actually appears in the textarea, which means the onchange event gets fired.
The test html is::
<td rowspan='4' nowrap='nowrap'  valign='top' align='left'>
<DIV id='win0divCLASS_SRCH_WRK2_SUBJECT$69$'><input type='text' name='CLASS_SRCH_WRK2_SUBJECT$69$' id='CLASS_SRCH_WRK2_SUBJECT$69$' tabindex='31' value=""  class='PSEDITBOX' style='width:60px; ' maxlength='8' onchange="addchg_win0(this);oChange_win0=this;"  />
</DIV></td>
The test code is::
        driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$"))
            .sendKeys("ACG");
        driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$"))
            .sendKeys("");
        Select sCourse= new Select(driver.findElement开发者_JAVA技巧(By.id("CLASS_SRCH_WRK2_ACAD_CAREER")));
        sCourse.selectByValue("");
The test sets the textelement, and then sets the select/option of a select item, which should trigger the change in focus. I also tried to clear, and reset the text, thinking that might trigger the onchange..
A solution to this would help a lot of people who've been looking for the same thing!!
Thanks
Have you tried doing a tab after sendKeys? You can do a driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$")) .sendKeys("\t");
I had a similar problem (though my trigger was onBlur). I called the blur() method directly. In your case it would be
driver.findElement(By.name("CLASS_SRCH_WRK2_SUBJECT$69$")).sendKeys("ACG");
((JavascriptExecutor)driver).executeScript( "$('[name=\"CLASS_SRCH_WRK2_SUBJECT$69$\"]' ).blur() );
You might need a different function other than blur().
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论