我有一个输入框,它还有两个箭头(向上和向下)来增加或减少它的值。
HTML
<span class="k-numeric-wrap k-state-default k-state-hover">
<input class="k-formatted-value k-input valid" type="text" tabindex="0" style="display: inline;" aria-disabled="false" aria-readonly="false"/>
<input id="DisplayOrder" class="k-input valid" type="text" value="0" name="DisplayOrder" data-val-required="'Display Order' must not be empty." data-val-number="The field Display order must be a number." data-val="true" data-role="numerictextbox" role="spinbutton" style="display: none;" aria-valuenow="1" aria-disabled="false" aria-readonly="false"/>
<span class="k-select">
<span class="k-link" unselectable="on">
<span class="k-icon k-i-arrow-n" title="Increase value" unselectable="on">Increase value</span>
</span>
<span class="k-link" unselectable="on">
<span class="k-icon k-i-arrow-s" title="Decrease value" unselectable="on">Decrease value</span>
</span>
现在,我首先尝试清除此输入字段,然后尝试输入值1,最后使用增量按钮将值1增加到2。
我的代码是
@FindBy(xpath="//span[@class='k-numeric-wrap k-state-default']") WebElement Category_Display_Order;
@FindBy(xpath="//span[@class='k-link']//span[@title='Increase value']") WebElement Category_Increase_Value;
Category_Display_Order.clear();
Category_Display_Order.sendKeys("1");
Category_Increase_Value.click();
但这样做 - 我收到错误
org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与之交互 命令持续时间或超时:10.03秒
答案 0 :(得分:0)
我认为你在错误的元素上使用sendKeys()
,这就是你遇到麻烦的原因。你应该尝试如下: -
@FindBy(id ="DisplayOrder")
WebElement Category_Display_Order;
@FindBy(css ="span[title='Increase value']")
WebElement Category_Increase_Value;
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOf(Category_Display_Order));
Category_Display_Order.clear();
Category_Display_Order.sendKeys("1");
wait.until(ExpectedConditions.visibilityOf(Category_Increase_Value)).click();
答案 1 :(得分:0)
我发现您的xpath选择器不正确。
尝试使用这些元素引用选择器:
import matplotlib.pyplot as plt
import geopandas as gpd
from descartes import PolygonPatch
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
def plotCountryPatch( axes, country_name, fcolor ):
# plot a country on the provided axes
nami = world[world.name == country_name]
namigm = nami.__geo_interface__['features'] # geopandas's geo_interface
namig0 = {'type': namigm[0]['geometry']['type'], \
'coordinates': namigm[0]['geometry']['coordinates']}
axes.add_patch(PolygonPatch( namig0, fc=fcolor, ec="black", alpha=0.85, zorder=2 ))
# plot the whole world
#ax2 = world.plot( figsize=(8,4), edgecolor=u'gray', cmap='Set2' )
# or plot Africa continent
ax2 = world[world.continent == 'Africa'].plot(figsize=(8,8), edgecolor=u'gray', cmap='Pastel1')
# then plot some countries on top
plotCountryPatch(ax2, 'Namibia', 'red')
plotCountryPatch(ax2, 'Libya', 'green')
# the place to plot additional vector data (points, lines)
plt.ylabel('Latitude')
plt.xlabel('Longitude')
#ax2.axis('scaled')
plt.show()
让我知道问题是否解决。