技术:
HTML:
<a href="/lightning/o/Acq_Prospect__c/home" title="Acq Prospects" tabindex="0" draggable="false" aria-describedby="operationId-20" class="slds-context-bar__label-action dndItem" style="" xpath="1"></a>
代码试用:
driver.findElement(By.xpath("//a[@title='Acq Prospects']"));
driver.findElement(By.linkText("Acq Prospect"));
错误:
Unable to find an element
答案 0 :(得分:0)
您只需要等待对象可见即可。您可以使用以下代码;
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.Until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@title='Acq Prospects']")));
更多信息; link。
注意:此外,请确保没有任何元素覆盖您要查找的对象。
答案 1 :(得分:0)
要找到所需的元素,您需要为 elementToBeClickable 引入 WebDriverWait ,并且可以使用以下任一解决方案:
threshold_scale = np.linspace(df_value_counts['Count'].min(),
df_value_counts['Count'].max(),
6, dtype=int)
threshold_scale = threshold_scale.tolist()
threshold_scale[-1] = threshold_scale[-1] + 1
sf_map.choropleth(
geo_data=sf_geo,
data=df_value_counts,
columns=['Neighborhood', 'Count'],
key_on='feature.properties.name',
fill_color='YlOrRd',
fill_opacity=0.7,
line_opacity=0.2,
threshold_scale=threshold_scale,
legend_name='Crime Rate in San Francisco')
sf_map
:
import java.sql.*;
class OracleDBCon
{
public static void main(String args[])throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","dypim12345");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from stud");
while(rs.next()){
System.out.println(rs.getString(1)+" "+rs.getString(2));
}
con.close();
}
}
cssSelector
:
WebElement Acq_Prospects = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.slds-context-bar__label-action.dndItem[href='/lightning/o/Acq_Prospect__c/home']")));