python和selenium发送密钥

时间:2018-02-08 15:54:11

标签: python selenium

我尝试将输入添加到文本框中,当我尝试它时没有找到该元素并且它给出了错误我不知道我是否选择了正确的元素这是我到目前为止所拥有的

Add-Migration migrationname

代码abouve是我得到的错误消息

@SpringBootApplication
public class Application {
   @Bean
   public FilterRegistrationBean squigglyRequestFilter() {
     FilterRegistrationBean filter = new FilterRegistrationBean();
     filter.setFilter(new SquigglyRequestFilter());
     filter.setOrder(1);
     return filter;
   }

   public static void main(String[] args) {
     new MyApplicationContextInitializer().initialize(SpringApplication.run(Application.class, args));
   }
}

public class MyApplicationContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

    @Override
    public void initialize(ConfigurableApplicationContext context) {
        //context.refresh()
        Iterable<ObjectMapper> objectMappers = context.getBeansOfType(ObjectMapper.class).values();

        Squiggly.init(objectMappers, new RequestSquigglyContextProvider());

        ObjectMapper objectMapper = Iterables.getFirst(objectMappers, null);

        // Enable Squiggly for Jackson message converter
        if (objectMapper != null) {
            for (MappingJackson2HttpMessageConverter converter : context.getBeansOfType(MappingJackson2HttpMessageConverter.class).values()) {
                converter.setObjectMapper(objectMapper);
            }
        }
    }
}

每当它进入脚本的末尾时,它就会输入并停止

[1]:https://www.footlocker.com/checkout/?uri=checkout这是我试图查看的页面

1 个答案:

答案 0 :(得分:2)

FIRST NAME 是要填写的必填字段,因此,send_keys(Keys.RETURN)尝试将expected_condition作为element_to_be_clickable发送,而不是ui.WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='billFirstName']"))) browser.find_element_by_xpath("//input[@id='billFirstName']").click() browser.find_element_by_xpath("//input[@id='billFirstName']").clear() browser.find_element_by_xpath("//input[@id='billFirstName']").send_keys("user_first_name") 。 }:

print