Home>

I am a python beginner. I started to use selenium.

Even if you can access the element of the

button, nothing changes when you click.
Since there was javascript at the time of click in html, I tried to move it, but the situation is the same.
Since selenium itself is taking screenshots, it works properly
think.

driver.save_screenshot ('/ home/sun/screenshot0.png')
#search_box = driver.find_element_by_id ("button_search")
#print (search_box.is_displayed ())
#valString = search_box.get_attribute ("type")
#print (valString)
#valString = search_box.get_attribute ("class")
#print (valString)
#print (search_box.text)
#print (search_box.location)
# search_box.click ()
driver.execute_script ("$('# button_search'). click (function () (var nextPage = 'CattleSearch/search/agreement';window.open (nextPage, '_blank');return false;});")


time.sleep (2)
driver.save_screenshot ('/ home/sun/screenshot1.png')
# search_box.submit ()

# driver.save_screenshot ('/ home/sun/screenshot2.png')
driver.quit ()
$(function () {
    // Click to search individual ID number
    $('# button_search'). click (function () {
        var nextPage = 'CattleSearch/search/agreement';
        window.open (nextPage, '_blank');
        return false;
    });
}

<p><button type = "button">Search for individual identification number</button></p>
  • Answer # 1

    driver.find_element_by_id ('button_search'). click ()
    driver.switch_to.window (driver.window_handles [1])


    How about it?

  • Answer # 2

    Did you use the .click () function?

    https://qiita.com/kinpira/items/383b0fbee6bf229ea03d#%E3%83%9C%E3%82%BF%E3%83%B3%E3%82%92%E3%82%AF%E3% 83% AA% E3% 83% 83% E3% 82% AF% E3% 81% 97% E3% 81% A6% E3% 81% BF% E3% 82% 8B