<label for="CREDIT" class="_8J-bZE _3C6tOa _2i24Q8">
<input type="radio" class="_2haq-9" name="paymentOptions" readonly="" id="CREDIT" value="on">
<div class="_6ATDKp"></div>
<div class="_2o59RR">
</div>
</label>
<label for="NET_OPTIONS" class="_8J-bZE _3C6tOa _2i24Q8">
<input type="radio" class="_2haq-9" name="paymentOptions" readonly="" id="NET_OPTIONS" value="on">
<div class="_6ATDKp"></div>
<div class="_2o59RR"></div>
</label>
有两个具有相同类名的单选按钮,我想单击第二个(NET OPTIONS)。我是python和selenium的新手,任何帮助都会得到满足。我已经尝试过Xpath并找到ID但仍然没有成功
driver.find_element_by_id("NET_OPTIONS").click()
driver.find_element_by_xpath("//*[@id='container']/div/div[1]/div/div/div[1]/div[4]/div/div/div/div[3]/div/label[3]").click()
尝试上面的代码后,我收到此错误,但是单选按钮在页面上非常明显但是,webriver是能够找到它的:( .selenium.common.exceptions.ElementNotVisibleException:消息:元素不可见
答案 0 :(得分:1)
试试这段代码,看看它是否有效 -
isBadSide = [1,1,1,0,0,0]
def R(s):
if isBadSide[s-1]:
return -s
return s
def T(s, a, N):
return [(1./N, s)]
def value_iteration(N, epsilon=0.001):
"Solving an MDP by value iteration. [Fig. 17.4]"
U1 = dict([(s, 0) for s in range(1, N+1)])
while True:
U = U1.copy()
delta = 0
for s in range(1, N+1):
U1[s] = R(s) + max([sum([p * U[s1] for (p, s1) in T(s, a, N)])
for a in ('s', 'g',)])
delta = max(delta, abs(U1[s] - U[s]))
if delta < epsilon:
return U
print(value_iteration(6))
# {1: -1.1998456790123457, 2: -2.3996913580246915, 3: -3.599537037037037, 4: 4.799382716049383, 5: 5.999228395061729, 6: 7.199074074074074}
答案 1 :(得分:0)
这非常简单。假设driver
是您的Selenium webdriver,您只需通过它id
找到它就可以点击您想要的按钮:
button = driver.find_element_by_id("NET_OPTIONS")
button.click()