I want my code to enter value in the box below and move to the next page. I'm using selenium in Python to do this.
This is the HTML for the element.
<input name="ctl00$SPWebPartManager1$g_d6877ff2_42a8_4804_8802_6d49230dae8a$ctl00$txtPageNumber" type="text" value="260" maxlength="5" onchange="return ValidateNumber(this);setTimeout('__doPostBack(\\'ctl00$SPWebPartManager1$g_d6877ff2_42a8_4804_8802_6d49230dae8a$ctl00$txtPageNumber\\',\\'\\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;javascript:return isNumber(event);" id="ctl00_SPWebPartManager1_g_d6877ff2_42a8_4804_8802_6d49230dae8a_ctl00_txtPageNumber" onpaste="return false;" style="width:60px;">
This is my code. How should get this to perform 'onkeypress' function?:
for i in range (2,10307): #looping over the page numbers
wait.until(EC.presence_of_element_located((By.ID, "ctl00_SPWebPartManager1_g_d6877ff2_42a8_4804_8802_6d49230dae8a_ctl00_txtPageNumber"))).send_keys(i)
等待元素之后,由于只需要onkeypress函数,请尝试执行脚本。
driver.execute_script("if (WebForm_TextBoxKeyHandler(event) == false) return false;javascript:return isNumber(event);")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.