I'm new here and new to Selenium. I have an SPA that is written in AngularJS. I'm trying to test a view with Python webdriver but it can't find the elements in the routed page. My question is how can I test the routed page?
view<div id ="form" align="center" ng-controller = "BP">
<input id = "topNumber" ng-model ="topNum" placeholder="Top Number" type ="number" class="form"/>
<br><br>
<input id = "botNumber" ng-model="bottomNum" placeholder="Bottom Number" type="number" class ="form"/>
<br><br>
<button class ="form" id ="bp_enter" ng-click="write(topNum, bottomNum)">Enter</button>
</div>
code
current python attempt
from selenium import webdriver
path = r'C:\Users\Mason\Desktop\chromedriver.exe'
var = webdriver.Chrome(path)
var.get("http://localhost/PhpProject30/index.php#!/")
var.find_element_by_id('home').click()
var.find_element_by_id('bp_btn').click()
var.find_element_by_id('BP_enter_btn').click()
var.get("http://localhost/PhpProject30/index.php#!/BP_Enter")
var.find_element_by_id('bp_enter').click()
答案 0 :(得分:0)
事实证明Selenium正在快速执行。它在视图加载之前在视图中查找元素。我暂停了一下,以便在某个时候给出视图,它就像魅力一样。
我所做的就是以下
import time
time.sleep(.5)